#!/bin/bash ######################################## File Description ######################################## # Creation time:2020-05-30 # Project:07 # Task: 02 # Execute example:bash record-shell-x-x.sh # Detailed description: # About:http://linux.book.51xueweb.cn ################################################################################################## # reback start yum remove -y vsftpd pam pam-* # reback end #***************reader shell start*************** # Install vsftpd、PAM yum install -y vsftpd pam pam-* # Add vsftpd useradd -g ftp -d /home/vsftpd -s /sbin/nologin vsftpd # Creat and Configure vuser_passwd.conf cat > /etc/vsftpd/vuser_passwd.conf << EOF admin01 admin01@pwd admin02 admin02@pwd market01 market01@pwd market02 market02@pwd market03 market03@pwd design01 design01@pwd design02 design02@pwd develop01 develop01@pwd develop02 develop02@pwd develop03 develop03@pwd EOF # Compile vuser_passwd.conf db_load -T -t hash -f /etc/vsftpd/vuser_passwd.conf /etc/vsftpd/vuser_passwd.db # Configure PAM sed -ir 's/^/#/g' /etc/pam.d/vsftpd echo -n ' auth required pam_userdb.so db=/etc/vsftpd/vuser_passwd account required pam_userdb.so db=/etc/vsftpd/vuser_passwd ' >> /etc/pam.d/vsftpd # Creat folder mkdir -p /srv/ftp/admin mkdir -p /srv/ftp/market mkdir -p /srv/ftp/design mkdir -p /srv/ftp/develop # Give folder permission chmod -R 777 /srv/ftp/admin chmod -R 777 /srv/ftp/market chmod -R 777 /srv/ftp/design chmod -R 777 /srv/ftp/develop # Give ftp user permission chown -R ftp:ftp /srv/ftp # Look information of '/srv/ftp' ls -l /srv/ftp # Backup configuration file cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak1 # Configure vsftpd Global cat > /etc/vsftpd/vsftpd.conf << EOF ftpd_banner=Welcome to FTP Service. anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 anon_upload_enable=NO anon_mkdir_write_enable=NO dirmessage_enable=YES xferlog_enable=YES connect_from_port_20=YES chown_uploads=YES xferlog_file=/var/log/xferlog xferlog_std_format=YES #nopriv_user=vsftpd async_abor_enable=YES ascii_upload_enable=YES ascii_download_enable=YES chroot_local_user=YES chroot_list_enable=YES chroot_list_file=/etc/vsftpd/chroot_list chroot_list_enable=YES listen=YES pam_service_name=vsftpd userlist_enable=YES guest_enable=YES guest_username=vsftpd virtual_use_local_privs=YES allow_writeable_chroot=YES user_config_dir=/etc/vsftpd/vsftpd_user_conf EOF # Empty file of '/etc/vsftpd/chroot_list' > /etc/vsftpd/chroot_list # Configure file of '/etc/vsftpd/chroot_list' echo vsftpd > /etc/vsftpd/chroot_list # Creat folder of '/etc/vsftpd/vsftpd_user_conf' mkdir -p /etc/vsftpd/vsftpd_user_conf # Configure Market touch /etc/vsftpd/vsftpd_user_conf/admin01 cat > /etc/vsftpd/vsftpd_user_conf/admin01 << EOF ftpd_banner=Welcome to Market. local_root=/srv/ftp/admin write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES EOF cp /etc/vsftpd/vsftpd_user_conf/admin01 /etc/vsftpd/vsftpd_user_conf/admin02 # Configure Market touch /etc/vsftpd/vsftpd_user_conf/market01 cat > /etc/vsftpd/vsftpd_user_conf/market01 << EOF ftpd_banner=Welcome to Market. local_root=/srv/ftp/market write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES EOF cp /etc/vsftpd/vsftpd_user_conf/market01 /etc/vsftpd/vsftpd_user_conf/market02 cp /etc/vsftpd/vsftpd_user_conf/market01 /etc/vsftpd/vsftpd_user_conf/market03 # Configure Design touch /etc/vsftpd/vsftpd_user_conf/design01 cat > /etc/vsftpd/vsftpd_user_conf/design01 << EOF ftpd_banner=Welcome to Design. local_root=/srv/ftp/design write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES EOF cp /etc/vsftpd/vsftpd_user_conf/design01 /etc/vsftpd/vsftpd_user_conf/design02 # Configure Develop touch /etc/vsftpd/vsftpd_user_conf/develop01 cat > /etc/vsftpd/vsftpd_user_conf/develop01 << EOF ftpd_banner=Welcome to Develop. local_root=/srv/ftp/develop write_enable=YES anon_umask=022 anon_world_readable_only=NO anon_upload_enable=YES anon_mkdir_write_enable=YES anon_other_write_enable=YES EOF cp /etc/vsftpd/vsftpd_user_conf/develop01 /etc/vsftpd/vsftpd_user_conf/develop02 cp /etc/vsftpd/vsftpd_user_conf/develop01 /etc/vsftpd/vsftpd_user_conf/develop03 # Restart vsftpd systemctl restart vsftpd #***************reader shell end***************