When you run a scheduled task to copy files, you need to enter a password to run the SCP command. Here, you can use a public key to automatically enter the password.
Specific operations:
Requirement: Copy test.tar on 192.168.0.2to 192.168.0.3.
On the 192.168.0.2 Server:
Mkdir-P ~ /. SSH
Chmod 700 ~ /. SSH
Ssh-keygen-t rsa-P ""-f ~ /. Ssh/id_rsa
After the. Ssh directory is created in 192.168.0.3, copy ~ From 192.168.0.2 ~ /. Ssh/id_rsa.pub to 192.168.0.3 ~ /. In the SSH directory (SCP ~ /. Ssh/id_rsa.pub root@192.168.0.3 :~ /. Ssh ).
On the 192.168.0.3 Server:
Mkdir-P ~ /. SSH
Rename id_rsa.pub copied from 192.168.0.2 to authorized_keys (CP id_rsa.pub authorized_keys)
Chmod 600 ~ /. Ssh/authorized_keys
At this time copy do not need to enter the password: SCP test.tar root@192.168.0.3:/var/WWW
The following command can be automatically executed by placing it in a scheduled task.