Fred
Fred

Reputation: 21

How to setup ssh for no passwords from different accounts

I would like to ssh from user1@machine1.com to user2@machine2.com without passwords.

I can do this using passwords.

With using ssh-keygen to set up ~user1/.ssh/id_rsa on machine1.com and ~user1/.ssh/authorized_keys on machine2.com, using the instructions in ssh manual page, I can, from user1 on machine1.com "ssh user1@machine2.com" without any passwords. But I can not login without passwords using the same setup procedure, albeit substituting for the destination user2 for user1, i.e., from user1 on machine1.com "ssh user2@machine2.com" does not work without passwords.

The instructions I have found for doing this seem to suggest that I need a user2 account on machine1.com to setup the keys and then copy them to the user1 account on machine1.com and user2 on machine2.com appropriately. Is this so? Can the necessary keys be generated on machine1.com using account user1 for logging into user2 on machine2.com?

Update: I have tried this using a third computer machine3.com instead of machine2.com and it works as desired. I found several posts of the web with the same generic problem but without any solutions. Any WAGs at what might be the problem?

Thanks in advance

Upvotes: 0

Views: 241

Answers (1)

Rob
Rob

Reputation: 1143

You can copy the same data into ~user2/.ssh/authorized_keys on machine2 that you copied into ~user1/.ssh/authorized_keys, so you would basically reuse the same key for both accounts. It's up to you to decide if this is a good idea.

You can, however, also generate a second key, but then you'd have to explicitly specify on the command line which key file is to be used for authorization from machine1.

Upvotes: 1

Related Questions