The idea is to be able to ssh from user1@machine1 to user2@machine2, without being asked for a password.
To do it, run the following commands (all of them as user1@machine1):
- Create a ssa key on machine1:
ssh-keygen -t rsa - Copy the public key over to machine2:
cat ~/.ssh/id_rsa.pub | ssh user2@machine2 "cat - >> ~/.ssh/authorized_keys"
(you may need to accept the server's fingerprint (say Yes), and will need to type your password this time).
Note: This also works for doing ssh to the same machine, under a different user. Just make sure user1's id_rsa.pub key is added to user2's ~/.ssh/authorized_keys file.
Note2: SSH is very strict with respect to permissions. The .ssh dir MUST have "700" permissions mask, and authorized_keys must be a 600. Anything different (and if you create authorized_keys, it will likely be created with a different access mask) will make this authentication method fail, and move on to the next one (ie. ask for a password).
No comments:
Post a Comment