vsftpd腳本自動化運行編寫案例
阿新 • • 發佈:2018-08-08
ever systemctl fig gin passwd writeable .so use allow
#!/bin/bash
USER1=lin
USER1P=123
USER2=fan
USER2P=456
#close firewalld and selinux
setenforce 0
sed -ri ‘s/^(SELINUX=).*/\1disabled/g‘ /etc/sysconfig/selinux
systemctl stop firewalld
systemctl disable firewalld
#install software
cd /etc/yum.repos.d/
mv * /tmp/
curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
sed -i ‘s/\$releasever/7/g‘ /etc/yum.repos.d/163.repo
yum -y install wget epel-release vsftpd &>/dev/null
#touch list of user and passwd
cat >> /etc/vsftpd/vu.list <<EOF
$USER1
$USER1P
$USER2
$USER2P
EOF
#anzhaung db4
yum -y install db4* &>/dev/null
#jiang gang chuang jiang de list shiyong db4 zhuanhuawei myself
db_load -T -t hash -f /etc/vsftpd/vu.list /etc/vsftpd/vu.db
# shezhi quanxian
chmod 600 /etc/vsftpd/vu.*
#add user touch ftp
useradd -d /var/ftproot -s /sbin/nologin vftp
chmod 755 /var/ftproot/
# PAM renzheng
cp /etc/pam.d/vsftpd /etc/pam.d/vsftpd.bak
cat > /etc/pam.d/vsftpd <<EOF
#%PAM-1.0
auth required pam_userdb.so db=/etc/vsftpd/vu
account required pam_userdb.so db=/etc/vsftpd/vu
EOF
#xiu gai vftpd
cat >> /etc/vsftpd/vsftpd.conf <<EOF
guest_enable=YES
guest_username=vftp
user_config_dir=/etc/vsftpd/vusers_dir
allow_writeable_chroot=YES
EOF
# touch /etc/vsftpd/vuser_dir
if [ ! -d /etc/vsftpd/vusers_dir ];then
mkdir /etc/vsftpd/vusers_dir
fi
#she zhi vusers quanxian
cat >> /etc/vsftpd/vusers_dir/$USER1 <<EOF
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
EOF
touch /etc/vsftpd/vusers_dir/$USER2
#start service
systemctl start vsftpd &>/dev/null
systemctl enable vsftpd &>/dev/null
ss -antl
vsftpd腳本自動化運行編寫案例