Automatic script running for SFTP automation in Linux

Source: Internet
Author: User

Start to study the automatic upload script in Linux.

UPDATE: 2014.3.10. It has been verified. It is best to use the key ,.

Only one vomit blood can be highlighted {

The ftp port is blocked, and ftp is not necessarily installed on the linux server.

There are a large number of servers, and they can only be uploaded from the server to the log server (the sftp server is built using freesshd, which feels good ).

The number of servers is large, and installation packages are not allowed.

}

The focus is on the word "Automation. That is, non-interactive password authentication.

There are many ways of automation, since I am a cainiao, I don't know what python, c, ruby, and so on. %> _ <%...

Based on the existing batch experience, we should start with automated ftp.

Ftp is disabled ..

There are also sftp that coexist with ssh, and the company uses ssh to log on to the linux server, so sftp is generally installed on the server.

Ftp has the s parameter, automatically reads text content, and executes commands in the file.

Well, I have studied that sftp also has the-B parameter to run batchfile.

Wipe !! Then it is stuck here. The-B parameter can only run the cmd command, but cannot automatically authenticate the password. To avoid entering the password, you must use the ssh publickey for authentication !!

After multiple times of searching by Du Niang and Google, the following methods are taken:

1. Install lftp. There are already a large number of scripts on the Internet that use lftp and sftp for automatic password authentication.

Appendix:

Lftp-u $ USERNAME, $ PASSWORD sftp: // $ HOST <EOF

Cd $ SFTPBACKUP

Put $ BACKUP/$ DataBakName

Bye

EOF

2. set up private key to activate automatic logon with the key.

3. CT tool.

4. the sftp server may not be able to perform anonymous login without knowing it, and is still studying it ..

5. If it is not really ugly, mount-t cifs to mount the windows shared directory, and then copy the cp command directly. However, you need to install a cifs package.

Feeling 1 and 2 are the most reliable ..

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.