搭建简单samba文件共享服务
[root@localhost ~]# yum install -y samba
samba主配置文件
[root@localhost ~]# vi /etc/samba/smb.conf
# 全局配置
[global]
# 工作组,影响不大
workgroup = MYGROUP
# 欢迎信息,影响不大
server string = Samba Server Version %v
# 日志文件
log file = /var/log/samba/log.%m
# 日志文件大小,单位为KB
max log size = 50
# 认证方式,一般有user(要密码)和share(不要密码)
security = user
# 用户密码存储方式
passdb backend = tdbsam
共享实例一,不用密码登陆,只读,前提是全局设置内security = share
# 模块名称
[test1]
# 共享信息
comment = share all
# 共享目录
path = /tmp/share
# 工作组内是否可见
browseable = yes
# 是否允许匿名访问
public = yes
# 是否可写
writable = no
共享实例二,需要密码登陆,只读,前提是全局设置内security = user
# 模块名称
[test1]
# 共享信息
comment = share all
# 共享目录
path = /tmp/share
# 工作组内是否可见
browseable = yes
# 是否允许匿名访问
public = no
# 是否可写
writable = no
samba + httpd + changepassword
修改主配置文件
[root@localhost ~]# vi /etc/samba/smb.conf
pam password change = no
passwd chat = **NEW*UNIX*password* %nn *Retype*new*UNIX*password* %nn *successfully*
passwd program = LANG=en_US /usr/bin/passwd %u
unix password sync = yes
passdb backend = smbpasswd
smb passwd file = /etc/samba/smbpasswd
并把passdb backend = tdbsam行注释或删除掉
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
找到#AddHandler cgi-script .cgi,把前面的注释符号#删除
找到<Directory "/var/www/html">这个模块内Options Indexes FollowSymLinks 行,末尾加ExecCGI
把changepassword-0.9.tar.gz包上传到服务器,开始安装
[root@localhost ~]# mkdir -pv /var/smb
[root@localhost ~]# chmod 777 /var/smb/
[root@localhost ~]# tar zxvf changepassword-0.9.tar.gz
[root@localhost ~]# cd changepassword-0.9
[root@localhost changepassword-0.9]# vi /root/changepassword-0.9/conf.h
char TMPFILE[]="/tmp/changepassword-shadow-XXXXXX";
char TMPSMBFILE[]="/tmp/changepassword-smb-XXXXXX";
char TMPSQUIDFILE[]="/tmp/changepassword-squid-XXXXXX";
修改为
char TMPFILE[]="/var/smb/changepassword-shadow-XXXXXX";
char TMPSMBFILE[]="/var/smb/changepassword-smb-XXXXXX";
char TMPSQUIDFILE[]="/var/smb/changepassword-squid-XXXXXX";
[root@localhost changepassword-0.9]# ./configure --enable-cgidir=/var/www/html/ --enable-language=English --enable-smbpasswd=/etc/samba/smbpasswd --disable-squidpasswd --enable-logo=1122.jpg
手工把1122.jpg拷贝到/var/www/html目录下
[root@localhost ~]# /etc/init.d/smb restart ; /etc/init.d/httpd restart
[root@localhost ~]# chkconfig smb on ; chkconfig httpd on
附录
[root@localhost ~]# useradd aa1
[root@localhost ~]# passwd aa1
[root@localhost ~]# smbpasswd -a aa1 #为aa1用户设置samba密码
[root@localhost ~]# smbpasswd -d aa1 #锁定aa1用户,禁止登陆samba
[root@localhost ~]# smbpasswd -e aa1 #启用aa1用户,允许登陆samba
[root@localhost ~]# smbpasswd -x aa1 #删除aa1用户的samba
changerpassword的官网:http://changepassword.sourceforge.net/
Changepassword下载地址
http://sourceforge.net/projects/changepassword/files/changepassword/0.9/changepassword-0.9.tar.gz
访问地址
http://IP/changepassword.cgi
samba进阶设定思路,利用samba create mask 、directory mask 和valid users 参数,配置系统权限进行设定。