轉載於http://www.linuxdiyf.com/linux/24260.html
1、開始需要我們做的是先在我們的ubuntu下安裝好samba:
安裝samba:sudo apt-get install samba
安裝smbclient:sudo apt-get install smbclient
2、修改配置文件
vi /etc/samba/smb.conf 編輯smb.conf 文件
在配置文件的最末尾加上:
[share]
comment = Shared Folder require password
path = /home/share
public = yes
writable = yes
valid users = share
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup
available = yes
browseable = yes
保存后重新啟動samba:sudo /etc/init.d/samba restart
3、設置用戶和密碼
sudo smbpasswd -a share 接着俺提示輸入密碼。(前提是添加了此用戶:useradd share)
否則系統在沒有此用戶的前提下按默認操作是會報如下錯的:
增加samba用戶提示Failed to add entry for user
root@tyc-virtual-machine:/home# smbpasswd -a share
New SMB password:
Retype new SMB password:
Failed to add entry for user share.
解決辦法:
這是因為沒有加相應的系統賬號,所以會提示Failed to add entry for user的錯誤,只需增加相應的系統賬號share就可以了:
root@tyc-virtual-machine:/home# groupadd share -g 6000
[root@tyc-virtual-machine:/home# useradd share -u 6000 -g 6000 -s /sbin/nologin -d /dev/null
4、最后計算機下右鍵添加一個網絡位置
輸入 文件夾框 \\ip地址\share,按提示輸入用戶名密碼即可。




附加:
為了增加系統的安全性,該文件夾只想給share用戶有讀寫權限即可!
[root@ubuntu ~]# chown -R share /home/share/
若不想讓另人訪問,只讓share用戶可以訪問,只需執行命令:
[root@ubuntu ~]# chmod u+rwx,g+rwx,o-rwx /home/share