Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since our server admin has left it would be a good time to change the login key for root? How do we go about this?

share|improve this question
up vote 2 down vote accepted

You will need to generate a new keypair, add the generated public key to root's authorized_keys file and remove the current public key from the authorized_keys file too. The authorized_keys file should be found in root's $HOME/.ssh directory.

The format of the $HOME/.ssh/authorized_keys is one key per line, if you have more than one key, you will have to identify the one currently in use to remove it.

Generate a new key with the ssh_keygen command

ssh-keygen -t rsa -b 2048 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/iain/.ssh/id_rsa): /home/iain/.ssh/tmp/id_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/iain/.ssh/tmp/id_rsa.
Your public key has been saved in /home/iain/.ssh/tmp/
The key fingerprint is:
f6:96:81:f4:15:70:d7:df:3f:dc:5e:0e:85:b1:2e:83 iain@test.lan

Now add the new public key ( to root's authorized_keys file, test that you can log in correctly with it and then remove the old key.

You may want to consider disabling roots ability to log in directly to your server and have people who need root access log in using their own credentials and then use sudo to perform admin tasks.

share|improve this answer

Remove his public key and add your public key.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.