scp remotely download files with a password on the command line

sshpass-Linux command of the non-interactive SSH password authentication
ssh login password can not be specified on the command line. sshpass appeared to solve this problem. sshpass for non-interactive SSH password authentication is generally used in the sh script, no need to enter the password again.
It allows you to specify clear text password using the -p parameter, then log in directly to the remote server, it supports password from the command line, files, environment variables are read.
Steps are as follows:
1. Download
sshpass Download: http://sourceforge.net/projects/sshpass/ downloaded as a tar.gz compressed package.
2. tar.gz linux compressed package uploaded to the server, here to sshpass-1.06.tar.gz an example, the directory of the server storage / user /
3. Under the user directory, execute: CD / user
4. decompression
tar sshpass-1.06.tar.gz -zxvf
5. the decompressed files into the directory
execute: CD-sshpass 1.06
6. the installation directory specified
execute: ./ configure --prefix = / user / sshpass
Description: / user / sshpass is mounted sshpass route of.
7. Load
performed: make
then execute: make the install
8. The copy
execution: cp / user / sshpass / bin / sshpass / usr / bin /
Description: / user / sshpass sshpass is the path of the installation.
9. Test is installed successfully
performed: sshpass
there are suggested i.e. successful installation: Here Insert Picture Description10. Use
sshpass -p 'password' SCP -R & lt [email protected] : /user/count_fille.txt / User /
as follows: Here Insert Picture Description11. For execution timing of
(1) generating a file of .sh,
perform: VI testsshpass.sh
then paste the following, and save
# / bin / SH!
sshpass -p 'password' SCP -R & lt [email protected] : / User /count_fille.txt / the User /
(2) authorize
chmod + the X- testsshpass.sh
(3) Add Scheduled task
execution: crontab -e
Add the following
30 11 * * * /user/testsshpass.sh
saved, and then perform the service crond restart

Published 24 original articles · won praise 50 · views 30000 +

Guess you like

Origin blog.csdn.net/u013015301/article/details/89468461