CentOS一鍵ftp

來源:互聯網
上載者:User

標籤:

# Version      : 1.0# Author       : 果子# Date         : 2013-12-14 14:34:12# Description  : 只需要三步即可完成安裝#                chmod a+x install_vsftpd.sh#                ./install_vsftpd install_server 安裝相關服務#                ./install_vsftpd add_user   配置使用者資訊#                ./install_vsftpd start   啟動服務# Usage        : 在瀏覽器或電腦地址中輸入:ftp://192.168.0.1 即可訪問,192.168.0.1為主機地址。# More         : 後續將增加一些安全性控制和大量建立使用者###!/bin/bash#set -x #調試用allow=YESdeny=NOSname=vsftpdVFconf="/etc/vsftpd/vsftpd.conf"VFstart="/etc/init.d/vsftpd"VUser="/etc/vsftpd/vuser"VUCdirectory="/etc/vsftpd/vuconf"VFpam="/etc/pam.d/vsftpdd"VFDirectory="/var/www/html"DB4=db4DB4UTILS="db4-utils"DB4DEVEL="db4-devel"sys_tem="/lib64"http=apache#----------主設定檔--------------main_config(){    if [ -d $sys_tem ];then    echo "Your system is 64bit"    systems=$sys_tem    else    echo "Your system is 32bit"    systems=/lib    fi    #     touch $VFpam    sed -i ‘s/anonymous_enable=YES/anonymous_enable=NO/g‘ $VFconf    sed -i ‘s/#chown_uploads=YES/chown_uploads=NO/g‘ $VFconf    sed -i ‘s/#xferlog_file/xferlog_file/g‘ $VFconf    sed -i ‘s/#async_abor_enable=YES/async_abor_enable=YES/g‘ $VFconf    sed -i ‘s/#ascii_upload_enable=YES/ascii_upload_enable=YES/g‘ $VFconf    sed -i ‘s/#ascii_download_enable=YES/ascii_download_enable=YES/g‘ $VFconf    sed -i ‘s/#chroot_local_user=YES/chroot_local_user=YES/g‘ $VFconf    sed -i ‘s/pam_service_name=vsftpd/pam_service_name=vsftpdd/g‘ $VFconf    {    echo "guest_enable=$allow"    echo "guest_username=$http"    echo "user_config_dir=$VUCdirectory"    echo "virtual_use_local_privs=$allow"    } >> $VFconf    touch $VFpam    {    echo "auth sufficient $systems/security/pam_userdb.so db=$VUser"    echo "account sufficient $systems/security/pam_userdb.so db=$VUser"    } > $VFpam}#------------使用者配置-----------------------user_config (){    Uname=$1    userhome="local_root="    userworld="anon_world_readable_only="    userupload="anon_upload_enable="    usermkdir="anon_mkdir_write_enable="    userothen="anon_mkdir_write_enable="    userwrite="write_enable="    echo -e "\033[31;40m ===Now configure the config file=== \033[0m"    if [ -d $VUCdirectory ];then    echo "The directory $VUCdirectory exsits."    else    mkdir $VUCdirectory    fi    echo "Your want to configure user is :$Uname"    read -p "Please input user home directory(default $VFDirectory)" home_dir    if [ "x$home_dir" != "x" ]    then    VFDirectory=$home_dir    fi    echo "Your home directory is: $VFDirectory"    touch "$VUCdirectory/$Uname"  && echo -e "\033[31;40mSuccess to configure file=== \033[0m"    {    echo "$userhome$VFDirectory"    echo "$userwrite$allow"    echo "$userworld$deny"    echo "$userupload$allow"    echo "$usermkdir$allow"    echo "$userothen$allow"    } > $VUCdirectory/$Uname    chown -R $http:$http $VFDirectory    chmod -R 755 $VFDirectory}#----------------增加使用者---------------------add_user(){    echo "start add user..."    while [ 1 ]    do    isok=y    echo -n "Do you want to add user?"    read -p "[Y/N]:" ok    if [ "x$ok" = "x" ]    then        continue    elif [ "x$ok" = "xN" ]    then        echo "=============Finish add user============="        break    fi    isok=$ok    if [ "x$isok" != "xY" ]    then        echo "Error input! please input Y/N "        continue    else        read -p "Input username: " username        read -p "Input userpasswd: " userpasswd        echo "Your username is: $username"        echo "Your userpasswd is: $userpasswd"        {        echo "$username"        echo "$userpasswd"        } >> $VUser        user_config $username    fi    done    db_load -T -t hash -f  $VUser $VUser.db}#-----------------安裝服務---------------------install_server(){    rpm -q $Sname    if [ $? -eq 0 ];then    echo "vsftpd service has installed. "    else    yum install -y $Sname    fi    yum -y install "db4*"}#------------------------------------------------case $1 in    install_server)    echo "start install $Sname:"    install_server    main_config    ;;    add_user)    add_user    ;;    restart)    $VFstart restart    ;;    start)    $VFstart start    ;;    stop)    $VFstart stop    ;;    *)    echo "Usage: $0 install_server|add_user|restart|start|stop"    exit 1esacexit 0

 

CentOS一鍵ftp

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.