1

安装

sudo apt-get install samba
sudo apt-get install smbclient

安装完成后查看是否安装成功

samba -V

配置

sudo vi /etc/samba/smb.conf 

加入内容

[share]
   comment = share folder
   browseable = yes
   path = /var/code
   create mask = 0777
   directory mask = 0777
   admin users = username
   valid users = username
   force user = nobody
   force group = nogroup
   public = yes
   available = yes
   writable = yes
   force create mode = 0644
   force directory mode = 0755

如果有多个不同位置的问题夹

[share]
   comment = share folder
   browseable = yes
   path = /var/code
   create mask = 0777
   directory mask = 0777
   admin users = username
   valid users = username
   force user = nobody
   force group = nogroup
   public = yes
   available = yes
   writable = yes
   force create mode = 0644
   force directory mode = 0755
[share2]
   comment = share2 folder
   browseable = yes
   path = /home/cs/shares2
   create mask = 0777
   directory mask = 0777
   admin users = username
   valid users = username
   force user = nobody
   force group = nogroup
   public = yes
   available = yes
   writable = yes
   force create mode = 0644
   force directory mode = 0755

重启

/etc/init.d/nmbd restart

/etc/init.d/samba restart

设置密码

sudo smbpasswd -a username

ufw 开放端口

1)Port 137 (UDP) - NetBIOS 名字服务
2)Port 138 (UDP) - NetBIOS 数据报服务
3)Port 139 (TCP) - 文件和打印共享
4)Port 389 (TCP) - LDAP
5)Port 445 (TCP) - NetBIOS
6)Port 901 (TCP) - 网页管理Samba  

访问

在 Windows 电脑文件管理器的地址中输入 \\ipaddress 访问,比如 \\192.168.0.23

输入用户名密码进入后,右键远程文件夹选择用 vscode 打开,即可实时修改 linux 上的代码


海光
1.1k 声望9 粉丝