以下是在Ubuntu 12.04中的安装和配置过程:
备注:以下是在非root用户下的配置,如果是在root用户下,把sudo 去掉即可。
1.安装samba:
samba:
sudo apt
-
get install samba
smbclient:
sudo apt
-
get install smbclient
2.修改配置文件:
sudo vi
/
etc
/
samba
/
smb.conf
在文件末尾加上如下[share] (相当于在home目录项增加了一个新用户)
[share]
comment = Share Folder require password
browseable = yes
path = /home/share
create mask = 0777
directory mask = 0777
valid users = wry1224
force user = nobody
force group = nogroup
public = yes
writable = yes
available = yes
3.设置用户wry1224登入samba的密码和保存退出后重启samba:
root@ubuntu:/# smbpasswd -a wry1224
New SMB password:
Retype new SMB password:
root@ubuntu:/# smbd restart
4. 切换到 /home/目录下创建一个用户目录:
sudo mkdir share
5.设置目录的权限: (777代表最高权限,可读可写可执行)
chmod 777 share
6./etc/samba/smb.conf 文件配置
[global]
workgroup = WORKGROUP
display charset = UTF-8
unix charset = UTF-8
dos charset = cp936
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
# public shares, not just authenticated ones
usershare allow guests = no
[share]
comment = Share Folder require password
browseable = yes
path = /home/share
create mask = 0777
directory mask = 0777
valid users = wry1224
force user = nobody
force group = nogroup
public = yes
writable = yes
available = yes
7. /etc/samba/smbusers文件添加如下内容
wry1224="network username"
8.最后打开我的电脑,空白位置右键添加一个网络位置
输入 \\IP地址(linux)\share 按提示步骤输入用户名和密码(samba 的用户名和密码)。
设置无密码访问配置如下:
Find the ### Authentication ### section (might be called Administration in older versions of Samba), where it says
security = user
Change it to
security = share
and make sure the line does not start with a semicolon. If it does, remove it.
A few lines down from that you’ll see
; guest account = nobody
Remove the semicolon at the beginning of the line.
Scroll to the very bottom of the file and put in the following, adjusted for your own system
[Share name]
writable = yes
path = /home/share
public = yes
guest ok = yes
guest only = yes
guest account = nobody
browsable = yes
Save the file and quit
In the terminal restart the samba server to reload the conf file
sudo /etc/init.d/samba restart