这里记录一下,以Ubuntu 14.04为例。
1.安装samba服务器。
sudo apt-get install samba
2.修改配置文件
sudo vim /etc/samba/smb.conf
然后找到home目录共享的部分,大概是190-214行,将前面的注释去掉,如下:
# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \serverusername
[homes]
comment = Home Directories
browseable = yes
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no
# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0666
# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0755
# By default, \serverusername shares can be connected to by anyone
# with access to the samba server.
# Un-comment the following parameter to make sure that only "username"
# can connect to \serverusername
# This might need tweaking when using external authentication schemes
valid users = %S
这里的掩码我稍微做了修改。
3.修改samba用户密码。
例如我的用户名是wing,那么需要创建一个相应的密码,用于samba共享,这个密码跟系统账户那个是不同的。
sudo smbpasswd -a wing
然后重启samba服务
sudo service smbd restart
4.在windows的资源管理器中打开\192.168.1.6homes(这里我的IP为192.168.1.6),输入用户名和密码(注意是刚才设置的samba用户密码),就可以看到设置成功。
如果感觉不太方便,可以把这个地址映射为文件夹或者一个虚拟的磁盘。