PublicKey Authentication
Hello!
I'm attempting to get ssh access to a server that has PublicKey Authentication. I added my ssh key to the authorized users via Lish. I do have two ssh keys on my machine and when I use ssh -vvv it seems like based on the output that it is working with the one key but not the other. However, even when I then specify which key with ssh -i /path/to/key root@IP it still says Permission denied (publickey).
Any assistance would be much appreciated!
1 Reply
You can try adjusting your ~/.ssh/config file to specify which SSH key is used for which server. For example:
Host shortname name.example.com
HostName name.example.com
IdentityFile ~/.ssh/locationofprivatekey
User usernameforlinode
Host name2 name2.example2.com
HostName name2.example2.com
IdentityFile ~/.ssh/locationofprivatekey2
User usernameforlinode
You can also instruct the ~/.ssh/config file to try multiple SSH keys in succession. This wouldn't require you to specify which key matches each server. Here's a sample of how this would work:
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/id_rsa_former
IdentityFile ~/.ssh/id_rsa_Linode
You may also need to check the file permissions and ownership on your non-working SSH key to ensure it is set up properly. I'd also suggest checking out this StackOverflow thread, which provides details about the above methods and a few other tips for getting multiple SSH keys to work successfully.