I'd say the safest solution to this is to generate a password-less SSH-key for each machine and add it to the authorized_keys list on the other.
On machine 1 (as the user who's logging on to the other server):
$ ssh-keygen -t rsa
$ ssh-add ~/.ssh/id_rsa
$ cat .ssh/id_rsa.pub
If keygen asks you for a password, just press enter to create a password-less key.
On machine 2:
- Create or edit
~/.ssh/authorized_keys
for the user that you're logging in with.
- Add the contents of
id_rsa.pub
(make sure it's the .pub file, not the private key) to the file. All of id_rsa.pub
should fit on a single line.
When this is done you should be able to do this from machine 1:
$ ssh username@machine-2
and just be logged in without entering your password. Same goes for scp/sftp.
If this doesn't work, make sure that you have PubkeyAuthentication yes
in your /etc/ssh/sshd_config