Adding a public SSH key for root access
- Copy and paste the contents of the public key file for the SSH key you are granting access to, for example yourkeyname.pub It will look something like this:-
- Paste in to a new single line in /root/.ssh/authorized_keys on the server
- Save the file, and the SSH key you added will now have access to the server as root
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7sBaZnNypvT4tfPiEWEN2rrHKTV9pweD1BiFtOx1...I5f6GmQboRn1wpW61CjAYwNMTd yourname@yourcomputer
To remove access to the key, remove the line relating to that key from the authorized_keys file and save.