天天看點

linux shell vsftpd 匿名使用者

#!/bin/bash

###this script is install vsftpd####

yum -y remove vsftpd

yum clean all

yum -y install vsftpd

CONF=/etc/vsftpd/vsftpd.conf

echo "####write a file path####"

read -p "please write a filename,you best Combined with path:" dir

#####dir is a variable####

if [ -d "$dir" ];then

    rm -rf $dir

 else

      mkdir $dir

 fi

mkdir -p $dir/iso

chmod 755 $dir

  chmod 777 $dir/iso

 echo "#####vsftpd install#####"

 echo "#######/etc/vsftpd/vsftpd.conf#####"

 sed -i 's/#anon_upload_enable=YES/anon_upload_enable=YES/g' $CONF

 sed -i 's/#anon_mkdir_write_enable=YES/anon_mkdir_write_enable=YES/g' $CONF

 sed -i 's/userlist_enable=YES/userlist_enable=NO/g' $CONF

  #sed -i  '/\<userlist_enable\>/s/YES/NO/g' $CONF  ##this command same as before###

  cat >> $CONF << EOF

  anon_umask=022

  anon_root=$dir

  EOF

  ##sed -i '/tcp_wrappers/a anon_umask=022' $CONF

  ##sed -i "/tcp_wrappers/a anon_root=$dir" $CONF   ###this command same as cat---EOF###

  echo "########start server######"

 service vsftpd restart

  chkconfig --add vsftpd

 chkconfig --level 35 vsftpd  on

  iptables -F

  setenforce 0

 echo "##############it is ok##########"

copy到linux建立的檔案裡面,給權限然後直接執行,這個必須搭建了yum倉庫

本文轉自 jie783213507 51CTO部落格,原文連結:http://blog.51cto.com/litaotao/1186927,如需轉載請自行聯系原作者

繼續閱讀