I have a file in server A which I am able to do transfer to server B using scp. I need to do this through a cron entry. server B has a password. How do I perform this?
Asked
Active
Viewed 1.7k times
4
-
Here's a short but complete reference, including permission settings: http://www.linuxproblem.org/art_9.html – GuilhermeMesquitaX Jul 08 '15 at 12:57
2 Answers
8
Don't use password authentication. Use ssh keypairs.
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
From then on, you should be able to ssh from A to B (and by extension, scp
from A to B) without a password.

Petr Skocik
- 28,816
-
And, for extra security, you can restrict the commands that the key is allowed to run, and even what directories it can access with scp. – Gilles 'SO- stop being evil' Jul 08 '15 at 22:44
-
is there a detailed document from where I can follow the steps. I'm new to unix. – Karthik Jul 20 '15 at 10:21
0
Generate an ssh-key on server A using ssh-keygen. This will generate a private and public key pair in $HOME/.ssh
. Add the public key to the $HOME/.ssh/authorized_keys
file on server B.
You can use the man
command to get more information. The command man authorized_keys
will present the manual page that discusses authorized keys.
Try the following sites for discussions:
- Ubuntu SSH/OpenSSH/Keys
- ServerFault Simple SSH public/private key question
- DigitalOcean How To Set Up SSH Keys
-
is there a detailed document from where I can follow the steps. I'm new to unix. – Karthik Jul 20 '15 at 10:21
-