Using scp and ssh with automatic authentication
Follow these steps to allow the use of ssh
/scp
without having to enter a password. You will need to be root.
First, make sure the client has used
ssh
at least once. This will create the proper directory that is needed.On the master machine run the
ssh-keygen -t rsa
command. This will create some necessary files.If the
/root/.ssh/authorized_keys
file does not already exist on the client, you can runscp /root/.ssh/id_rsa.pub <hostname>:/root/.ssh/authorized_keys
.Otherwise, copy the
id_rsa.pub
file over to the client and then add it to theauthorized_keys
file (I usually put it at the bottom).You should now be able to
scp
andssh
to the client without having to enter a password. This is really handy, especially in scripts.
You can also add this entry to another user account. For example, I added it to my /home/guest1/.ssh/authorized_keys
file. This way I can copy files as root from one machine, and it will still be accepted by the other.