如何从 cron 将文件从服务器 A scp 到服务器 B?

Kar*_*hik 3 scripting password ssh scp cron

我在服务器 A 中有一个文件,我可以使用 scp 将其传输到服务器 B。我需要通过一个 cron 条目来做到这一点。服务器 B 有密码。我如何执行此操作?

PSk*_*cik 7

不要使用密码认证。使用 ssh 密钥对。

Karthik@A $: ssh-keygen    #keep the passphrase empty
Karthik@A $: ssh-copy-id B #enter your B password
#^ this will copy your public key to Karthik@B:.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)

从此,你应该能够从SSH(通过扩展,scp)没有密码。