5

I'm new to this so I hope I don't ask nonsense.

I want to send an SSH command to a remote server without password.

On the local machine we have multiple users.

On the remote machine there is only one user, so I have to connect with that_user@remote_server.

Is it possible to create RSA keys for all the users at local_machine (each user will add it's own) to the one user at remote server?

Thanks,

3 Answers3

10

Yes.

Please create your key on the source system (ssh-keygen -t rsa, for instance), then use the ssh-copy-id command to push it to the remote system.

The following should work for you:

ssh-copy-id that_user@remote_server 
ewwhite
  • 201,205
4

Yes, just run ssh-keygen -t rsa under each user, and then add the contents of ~/.ssh/id_rsa.pub file, or whatever file you chose to contain created ssh key, to the end of ~/.ssh/authorized_keys file in the home directory of the user on the remote server.

ralz
  • 2,861
  • 3
  • 19
  • 23
3

Yes, it's possible, have a look at this question: SSH public key authentication - can one public key be used for multiple users?

Basically you have to

  1. Create a private/public key pair for each user at local_machine, let's say id_rsa and id_rsa_.pub ; the keys will reside in each users' ~/.ssh/ folder.
  2. append the contents of each user id_rsa.pub into ~/.ssh/authorized_keys on remote-machine. You can do that remotely via

cat /home/newuser/.ssh/id_rsa.pub | ssh user@remote_machine "cat >> ~/.ssh/authorized_keys"