Ubuntu共享服务samba
官网
https://ubuntu.com/tutorials/install-and-configure-samba#3-setting-up-samba
安装
apt-get update
apt-get install samba
创建共享目录
mkdir /home/<username>/sambashare/
- sambashare:共享的目录名
编辑配置
官方案例
配置文件的路径:/etc/samba/smb.conf
- 编辑配置文件
sudo vim /etc/samba/smb.conf
- 参考配置
[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes
个人配置
我是将我的整个用户目录共享出来了
[ionc]
comment = ionc on Ubuntu
path = /home/ionc
read only = no
browsable = yes
writable=yes
deadtime = 30
重启服务
sudo service smbd restart
- 更新防火墙规则
sudo ufw allow samba
为用户设置密码
sudo smbpasswd -a username
- username: 主机上真实存在的用户
Reload Samba for every change to users/passwords or 'smb.conf'
sudo /etc/init.d/samba reload
If the above command doesn't work for you, try:
sudo smbd reload
连接
mac
On macOS: In the Finder menu, click Go > Connect to Server then enter
smb://172.16.85.129/ionc
win
On Windows, open up File Manager and edit the file path to:
\\ip-address\sambashare
Note: ip-address is the Samba server IP address and sambashare is the name of the share.