搭建samba、apache、changepassword,用户手动修改samba用户密码
一、源码安装samba:
1、源码安装samba服务器:
安装包版本samba-3.6.22.tar.gz,下载地址:http://samba.org/samba/ftp/samba-latest.tar.gz
# tar -xzvf samba-latest.tar.gz
编译安装
# cd samba-3.4.2/source3
source3目录里是samba-3.x的源文件,source4目录里是samba-4.x的源文件
# ./autogen.sh
# ./configure --prefix=/usr/local/samba
samba默认是安装在/usr/local/samba目录下,你可以通过指定prefix=your location的方式来指定安装目录
# make
# make install
配置动态链接库路径
# vi /etc/ld.so.conf
加入一行/usr/local/samba/lib
# ldconfig 不是i的大写而是L的小写
执行ldconfig命令让配置生效
2、配置samba服务器,修改smb.conf文件:
首先要将源代码包中/examples/smb.conf.default文件拷贝到/usr/local/samba/lib下,并将其改名为smb.conf,
[global]
security = user
load printers = yes
log file = /usr/local/samba/var/log.%m
max log size = 50
pam password change = no
passdb backend = smbpasswd
smb passwd file = /usr/local/samba/smbpasswd
注:上述修改其实将tdbsam认证方式修改该成smbpasswd,并将认证文件加密保存在/usr/local/samba/smbpasswd下
,所以编译安装changepassword时需要指定这个文件
[homes]
comment = Home Directories
browseable = no
writable = yes
[printers]
comment = All Printers
path = /usr/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
[public]
comment = Public Stuff
path = /home/samba
public = yes
writable = no
printable = no
public = no
writable = yes
printable = no
create mask = 0765
在/usr/local/samba/bin下面运行testparm程序,测试smb.conf文件:
[[email protected] ~]# cd /usr/local/samba/
[[email protected] samba]# cd bin/
[[email protected] bin]# pwd
/usr/local/samba/bin
[[email protected] bin]# ./testparm
Load smb config files from /usr/local/samba/lib/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[public]"
Loaded services file OK. ######OK则表示没问题
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
smb passwd file = /usr/local/samba/smbpasswd
passdb backend = smbpasswd
log file = /usr/local/samba/var/log.%m
max log size = 50
idmap config * : backend = tdb
[homes]
comment = Home Directories
read only = No
browseable = No
.......
3、启动samba服务器进程:
/usr/local/samba/sbin/smbd -D
/usr/local/samba/sbin/nmbd -D ####这个可以不用启动,启动的smbd进程之后nmbd守护进程就会自动启动。
[[email protected] bin]# ps -ef |grep smbd
root 11723 12538 0 03:49 ? 00:00:00 ./smbd
root 11769 4392 0 04:25 pts/1 00:00:00 grep --color smbd
root 12538 1 0 02:56 ? 00:00:00 ./smbd
root 12539 12538 0 02:56 ? 00:00:00 ./smbd
root 12559 12538 0 02:57 ? 00:00:00 ./smbd
4、添加samba服务器用户,注意用户必须是系统存在的用户:
useradd jame
passwd jame
/user/local/samba/bin/smbpasswd -a jame ####设置为samba服务器的用户
注:这里创建samba账户时必须设置系统账户密码,以及smb账户密码
因为changepassword更改密码的机制是,先修改系统账户密码,然后将系统账户密码同步到 /usr/local/samba/smbpasswd SMB密码库文件下。
这样添加了之后,在samba的配置文件中我们设置了密码保存在/usr/local/samba/smbpasswd文件中,我们可以查看这个文件:
5、验证:
访问成功,说明samba服务器我们已经搭建好了。
二、安装changepassword程序实现客户端更改密码,必须设置系统密码和samba密码同步
1、下载地址:http://prdownloads.sourceforge.net/changepassword/changepassword-0.9.tar.gz
# tar -zxvf changepassword-0.9.tar.gz
# cd changepassword-0.9
2.编译changepassword前需要安装一个依赖包
# cd smbencrypt/
# tar -xzvf libdes-4.04b.tar.gz
# cd des/
# make
# cp libdes.a ../
# cd ../..
3.编译安装changepassword
# ./configure -enable-cgidir=/usr/local/apache/htdocs/samba -enable-language=Chinese -enable-smbpasswd=/usr/local/samba/smbpasswd -disable-squidpasswd -enable-logo=samba/logo.jpg
注:-enable-cgidir=... # 自定义apache根目录路径
-enable-language=Chinese # 设置页面为简体中文
-enable-smbpasswd=/etc/samba/smbpasswd # 自定义samba密码的库文件
(这里smbpasswd并非修改smb用户密码的系统命令,请注意不要混淆)
-disable-squidpasswd # 禁用squid
-enable-logo=... # 设置web根目录logo文件,此处的相对路径对应的是apache根目录
# 也就是 samba/logo.jpg对应/usr/local/apache/htdocs/samba/logo.jpg
# make && make install
三、源码安装apache服务器:
准备安装环境
- yum -y install gcc* openssl-devel expat-devel openssl openssl-devel libxml2-devel glibc-common gd-devel
下载源码包
- wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz;
- wget http://archive.apache.org/dist/apr/apr-1.4.6.tar.gz
- wget http://archive.apache.org/dist/apr/apr-util-1.5.1.tar.gz
安装apr
- tar zxvf apr-1.4.6.tar.gz
- cd apr-1.4.6
- ./configure --prefix=/usr/local/apr
- make
- make install
如果在编译中出现如下报错
- /bin/rm: cannot remove `libtoolT': No such file or directory 编辑文件:vim configure--->将 RM='$RM'修改为 RM='$RM -f'即可。
安装apr-util
- tar zxvf apr-util-1.5.1.tar.gz
- cd apr-util-1.5.1
- ./configure --with-apr=/usr/local/apr
- make
- make install
安装apache
#tar zxvf httpd-2.2.23.tar.gz
#cd httpd-2.2.23
#./configure --prefix=/usr/local/apache --enable-dav --enable-so --enable-maintainer-mode --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config
#make
#make install
设置apache支持cgi模块
# vi /usr/local/apache2/conf/httpd.conf
搜索cgi 去掉如**释:
--------------
#LoadModule cgid_module modules/mod_cgid.so #####这个当时没有
AddHandler cgi-script .cgi
--------------
搜索 DocumentRoot,在/usr/local/apache/htdocs类目下找到Options选项,修改为:
--------------
Options Indexes FollowSymLinks ExecCGI
--------------
ServerName 127.0.0.1:80
-----------------
重启服务
# /usr/local/apache/bin/apachectl restart
5.访问web后台:
http://192.168.1.103/samba/changepassword.cgi
按照提示修改密码提交即可
清除window访问samba的缓存:
在次访问: