samba安装
1.检查是否安装samba
rpm -ql samba
rpm -ql samba-client
2.若未安装
yum -y install samba
yum -y install samba-client
3.确认安装完成
# rpm -qa | grep samba
samba-common-3.5.12-72.fc15.1.i686
samba-winbind-clients-3.5.12-72.fc15.1.i686
samba-client-3.5.12-72.fc15.1.i686
samba-3.5.12-72.fc15.1.i686
samba使用
samba客户端工具
1. smbtree 显示局域网中的所有共享主机和目录列表
用法:smbtree [-b][-D] [-Uusername%password]
2. nmblookup 显示一台足迹的netbios主机名
3. smbclient 显示/登陆局域网中的共享文件夹
用法:smbclient –L host
smbclient //host/share
4. smbtar 远程备份网上邻居中文件(需稍作修改)
用法:smbtar –s server –u user –p password–x sharename –t output
smbtar–s win2000 –u root –p 12345 –x sharedir –t backup.tar
挂载共享文件夹
# mount.cifs //192.168.137.1/swap /mnt/
# mount.cifs //192.168.137.1/swap /mnt/ -o username=test%123
samba服务器配置
1. 修改配置文件/etc/samba/smb.conf
workgroup= workgroup
security= share
[docs] //指定共享文件夹
path= /usr/share/doc
comment= share documents
public= yes
2. 重启动smb服务器
#servicesmb restart
#chkconfigsmb on //设置服务自动启动
3. 测试
#smbclient–L localhost
samba用户账号
1. 共享目录设置有效用户
[redhat]
path= /var/redhat
comment= redhat’s files
public= no
validusers = [username][@groupname]
2. 新建samba用户
#useraddusername
#smbpasswd–a username
smbpasswd--help
#smbpasswd–d username //disable
#smbpasswd–e username //enable
#smbpasswd–x username //删用户
#smbpasswd–n username //清密码
#smbpasswdusername //修改密码
3. 用户账号映射(防止猜测系统账户)
[global]
usernamemap = /etc/samba/smbusers
#vi/etc/samba/smbusers
用户名 = 虚拟用户名
HOME目录
用户分别的共享文件夹
[global]
[homes]
validusers = %S
browseable= no
writeable= yes
samba用户权限
[fedora]
path= /var/share
public= no
validusers = [usernaem][@groupname]
writelist = [usernaem][@groupname]
createmask = 0660
directorymask = 0770
允许写权限