vsftpd服务器学习(三)——脚本实现

#! /bin/sh
#add virtual users
touch /etc/vsftpd/virtual_users.txt
echo "xzc
liumang
byrlx
liumang">> /etc/vsftpd/virtual_users.txt
db_load -T -t hash -f /etc/vsftpd/virtual_users.txt /etc/vsftpd/virtual_users.db
chmod 600 /etc/vsftpd/virtual_users.db
rm -r /etc/vsftpd/virtual_users.txt
touch /etc/pam.d/ftp.vu
echo "auth required /lib/security/pam_userdb.so db=/etc/vsftpd/virtual_users
account required /lib/security/pam_userdb.so db=/etc/vsftpd/virtual_users" >> /etc/pam.d/ftp.vu
#add local user
useradd -d /var/ftp/virtual -s /sbin/nologin virtual
chown -R virtual.virtual /var/ftp/virtual
touch /tmp/new_ftppwd
echo "virtual:liumang" >> /tmp/new_ftppwd
chpasswd < /tmp/new_ftppwd
#modify vsftpd.conf
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak.00
echo "anonymous_enable=NO
anon_upload_enable=NO
local_enable=YES
local_umask=022
dirmessage_enable=YES
connect_from_port_20=YES
guest_enable=YES
guest_username=virtual
user_config_dir=/etc/vsftpd/user_conf
write_enable=YES
pam_service_name=ftp.vu
userlist_enable=YES
listen=YES
chroot_local_user=YES
tcp_wrappers=YES
xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=/var/log/xferlog
vsftpd_log_file=/var/log/vsftpd.log" > /etc/vsftpd/vsftpd.conf
#configure virtual users
mkdir -p /etc/vsftpd/user_conf
touch /etc/vsftpd/user_conf/xzc  /etc/vsftpd/user_conf/byrlx
echo "anon_world_readable_only=NO
write_enable=YES
anon_upload_enable=NO
anon_other_write_enable=NO
anon_mkdir_write_enable=NO" > /etc/vsftpd/user_conf/xzc
echo "anon_world_readable_only=YES
write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
anon_mkdir_write_enable=YES" > /etc/vsftpd/user_conf/byrlx
#restart vsftpd
service vsftpd restart
                                                                                                           55,1          Bot

 

 

你可能感兴趣的:(Security,F#,脚本)