First, install the configuration ftp:
# yum-y Install VSFTPD
# service VSFTPD Start
# SS-TUNLP | grep 21
// Add local FTP logged in user Ftpuser
# Useradd Ftpuser
# echo 123456 | passwd--stdin Ftpuser
# cd/etc/vsftpd/
# CP vsftpd.conf Vsftpd.conf.bak
# Vim Vsftpd.conf
// allow local users to log on FTP and the FTP have Write permissions
Local_enable=yes
Write_enable=yes
// allow only local users that you just added Ftpuser can log in normally FTP
Userlist_enable=yes
Userlist_deny=no
# echo Ftpuser > User_list
// Imprison Local Users Ftpuser In their home directory
Chroot_local_user=yes
# Service VSFTPD Restart
// installation FTP Client Tools
# yum-y Install FTP
# FTP 192.168.199.9
Two: using Shell script to implement FTP automatic upload and download files
FTP Server: 192.168.199.9
FTP Directory: /home/ftpuser , has been chroot to /
Local Directory: /software
// Let Ftpuser users to /software Directory has write permissions
# mkdir-pv/scripts
// from FTP Download The specified file to a local directory
# vim/scripts/ftp_download.sh
#!/bin/bash
Ftp-n-I 192.168.199.9 <<eof
User Ftpuser 123456
Binary
CD/
Lcd/software
Get apache-tomcat-8.0.45.tar.gz
Bye
Eof
echo "Download from FTP successfully."
Note: If you want to implement a bulk download file, you can Get apache-tomcat-8.0.45.tar.gz modified to Mget *
# chmod +x ftp_download.sh
// upload locally specified files to FTP
# vim/scripts/ftp_upload.sh
#!/bin/bash
Ftp-n-I 192.168.199.9 <<eof
User Ftpuser 123456
Binary
CD/
Lcd/software
Put apache-tomcat-8.0.45.tar.gz
Bye
Eof
echo "Upload to FTP successfully."
Note: If you want to implement a bulk upload file, you can put apache-tomcat-8.0.45.tar.gz modified to Mput *
# chmod +x ftp_upload.sh
Description
<<: File input redirection
EOF : Identifies the beginning and end of a file, paired-up
FTP Options:
- N : Disable automatic login
- I. : Turn off interactive prompts during multi-file transfer
User FTP Login User Name FTP Login Password
binary : Transferring files in binary format
CentOS 6.9 automatically uploads and downloads files using shell scripts for FTP