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?


  • Yes, it is possible. man authorized_keys Commented Jan 5, 2017 at 14:36
  • 1
    @GeraldSchneider No manual entry for authorized_keys
    – Jakuje
    Commented Jan 5, 2017 at 14:47

3 Answers 3



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 
  • Don't forget to mention to create an SSH key per user and push each public key for each user into that_user's authorized_keys file on the remote_machine.
    – user292698
    Commented Jan 8, 2017 at 17:54

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.

  • Assuming that all of the systems support it, it's likely better to be using ed25519 keys as opposed to RSA.
    – EEAA
    Commented Jan 5, 2017 at 16:29

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"

  • 4
    Why is this better than "ssh-copy-id that_user@remote_server"?
    – Elad Weiss
    Commented Jan 5, 2017 at 14:56
  • 1
    @EladWeiss Both ways have their pros and cons. It's easy to use the script but you can't be sure that it added the key correctly (I think the script even tells you that you need to take a look in authorized_keys yourself to make sure the key was added correctly). Some systems (OS X?) doesn't have the script at all, so then you need to add the key manually.
    – simon
    Commented Jan 5, 2017 at 20:43
  • 1
    @EladWeiss The script does more than just copy the key, i.e. changes permissions when it thinks it is needed, see here linux.die.net/man/1/ssh-copy-id Matter of fact, I'd rather just copy the key and take care of permissions myself. Commented Jan 7, 2017 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .