Install Samba

  • 切换到Root
$sudo -s
  • 安装Samba
#apt-get install -y samba samba-common python-glade2 system-config-samba
  • 备份并新建一份Samba空配置
#cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
#cat /dev/null  > /etc/samba/smb.conf

Samba Configure

Anonymous

  • 创建匿名共享配置
#vim /etc/samba/smb.conf
# /etc/samba/smb.conf

[global]
workgroup = WORKGROUP  
server string = Samba Server %v  
netbios name = ubuntu  
security = user  
map to guest = bad user  
dns proxy = no

[Anonymous]
path = /samba/anonymous  
browsable =yes  
writable = yes  
guest ok = yes  
read only = no  
force user = nobody  
  • 创建匿名共享目录并设置权限
#mkdir -p /samba/anonymous
#chmod -R 0775 /samba/anonymous
#chown -R nobody:nogroup /samba/anonymous
  • 重启服务
#service smbd restart

Secured

  • 创建私密共享配置
# 匿名共享配置下方添加
[secured]
 path = /samba/secured
 valid users = @smbgrp
 guest ok = no
 writable = yes
 browsable = yes
  • 创建私密共享目录并设置账户权限
#mkdir -p /samba/secured
#cd /samba
#chmod -R 0770 secured
#chown root:smbgrp secured
  • 重启服务
#service smbd restart

PS

  • 以上设置只能通过//x.x.x.x的IP形式访问,如想通过//ServerName方式访问需要设置本机hosts指向IP或使用自定义DNS服务
# C:\\Windows\System32\drivers\etc\hosts
192.168.1.1     server1.example.com server1  
  • smbpasswd似乎不支持复杂符号的密码