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 ..