I'm new to Linux, I'm having CentOS 7. I want to allow multiple users for one server (Path - /var/www/ folder) using ssh key based authentication. For that I have created 2 new users from my root account and created ssh key using ssh-keygen for the first user and transferred that to authorized keys file.

My question

Is when I create ssh key for 2nd user does the authorized keys file will get over written? If so how do I enable the ssh key for second user.

As per my knowledge, private key will be kept by the user and public key to be given to the rest. so in that case I need to generate ssh key from the user account and not from the root, then put that key in authorized keys file.

  • are you trying to add multiple users to same account? Jul 17, 2018 at 10:08

1 Answer 1


Supposing that you want multiple keys per account, then

Add one public key per line. In ~/.ssh/authorized_keys. To do this copy the keys to ~/.ssh, then do (cd ~/.ssh; cat *.pub > authorized_keys), alternatively you can add one key with cat new_key.pub >> authorized_keys.

However you probably don't want multiple users to share an account. It would be better to set up multiple accounts.

You must log in to answer this question.

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