Prerequisites
The system I use is as follows
System for sharing files: ubuntu version: 18.04.6
Target system: windows11
Install samba
sudo apt-get install samba
Modify configuration file
sudo vim /etc/samba/smb.conf
Add the following content at the end of the file
[share] # 共享的名称,可以自行定义
comment = file share # 描述
path = /home/admin/ # 共享文件的路径
available = yes # 可选操作
valid users = 用户名 # 这里填写下面设置的用户名,可选操作
read only = no # 是否只读
writable = yes # 是否有写入权限
browseable = yes
public = yes # 是否公开访问
create mask = 0644
directory mask = 0755
Set access password (optional)
Set username and password
sudo smbpasswd -a fw(fw为访问的用户名)
Enter the corresponding password
Solving the error problem: Failed to add entry for user fw. (There is no corresponding system account, so the error Failed to add entry for user will be prompted)
Error reporting and problem solving
Use system account
sudo smbpasswd -a admin(系统账号)
Just enter the corresponding password
Add system account
sudo groupadd fw(用户名) -g 6000
sudo useradd fw(用户名) -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
Just set the username and password again
successful result
Modify shared folder permissions
sudo chmod -R 777 /home/admin/
Restart samba service
sudo systemctl restart smbd
sudo systemctl restart nmbd
windows related configuration
Enable samba configuration
Find Control Panel => Programs => Turn Windows features on or off => SMB file sharing support
=> Check both SMB server and client options => Click OK
Add network drive
Open the resource manager (win+E) => Network => Right-click and select Map network drive => Enter the IP of the corresponding service and the defined share name (\\192.168.1.122\share) => Check Reconnect at login = > Click Done => Enter password => Click OK
If a password is set, the password input interface will pop up:
Add finishing effects
This computer => Network location. Click to see the shared file content.
summary
If you cannot access, remember to close the firewall or open ports 445 and 139.