這里記錄一下,以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 \\server\username
[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, \\server\username 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 \\server\username
# 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.6\homes(這里我的IP為192.168.1.6),輸入用戶名和密碼(注意是剛才設置的samba用戶密碼),就可以看到設置成功。
如果感覺不太方便,可以把這個地址映射為文件夾或者一個虛擬的磁盤。