How do I login to my Linode via SSH after switching computers?
I recently switched computers and am no longer able to login to my Linode via SSH. I keep getting the error message:
"Permission denied (publickey)"
How do I go about logging into my Linode from a new computer?
SSH key authentication works by authenticating you with a key pair. Each key pair has a public key and a private key. You add your public key to computers or servers that you would like to access with your private key.
If you have switched computers, you'll need to either copy your old private key over to your new computer or create a new key pair and add the public key that matches your new keypair to your Linode.
If you still have access to your to your old computer and your old computer ran Linux or MacOS, your key should be located in your user's
.ssh/ directory. For example, if my username on my laptop is "bo", my ssh keys live in
/Users/bo/.ssh. You can then copy that key over to your current computers /User/<your-user>/.ssh directory (create the directory if it doesn't already exist), set the correct permissions on the private key, add the key to your ssh-agent, and you should then be all set to log back into your Linode.
I always get mixed up with .ssh folder and key permissions, so I refer to this superuser article every time I make any changes to my ssh keys or move to a new computer:
If you do not have access to your old computer, you can generate a new key pair similar to how you did originally. We have a guide on doing so here:
Once you've created a new key pair, you'll have to add it to the .ssh/authorized_keys file for the user your are trying to log in as on your Linode. Since you can't login via ssh to add the key, you can use our Lish console to manually log in to your Linode and copy and paste the key into the authorized_key file. We have a guide on using Lish to connect to your Linode here:
If you have found that you have forgotten your root or user password for your Linode, you can reset your Linode's root password through your Linode's Dashboard by following the guide here:
Once you've reset your root password, you can login to your Linode via Lish and change the password of your user using the
passwd command. For example, if the user on my Linode was "bo", I would change the password for that user with the following command:
# logged in as the root user, run: $ passwd bo
After the password has changed, you can login back in via Lish and add the key to your authorized_keys file using your favorite text editor. We have a great guide on Linux users and groups and changing their attributes here: