CentOS 6.9 automatically uploads and downloads files using shell scripts for FTP

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.