I am facing an issue in Ubuntu 22.04.2. where I am unable to SSH into a remote server using a copied public key. I have generated an SSH key pair on my local machine using a bash terminal, and I have successfully copied the public key (id_rsa.pub) to the remote server. However, when I attempt to SSH into the server using the corresponding private key (id_rsa), I am still prompted to enter my password. I even went as far as to copy my file and put it in different directories to try and figure out where it's looking for my SSH key, but so far I've had no luck. What could be causing this issue and how can I resolve it?
My process:
Used mkdir
to create a .ssh directory on my server side. Inside of it contains a file named authorized_keys which contains my public key.
In my bash terminal, I used ssh-keygen
and generated two keys, id_rsa and id_rsa.pub
Verified I have both id_rsa and id_rsa.pub
used scp ~/.ssh/id_rsa.pub username@ip_address:~/.ssh/authorized_keys
it copies over correctly. Just to verify, I use nano to inspect the pub key on my server .
Update permissions. Use sudo chmod 700 ~/.ssh/
and sudo chmod 600 ~/.ssh/*
Despite closely following these steps and repeating them multiple times, I have had no luck fixing my issue. I have also explored solutions presented in threads, such as making sure that settings in /etc/ssh/sshd_config are properly updated as well. Tried flipping PasswordAuthentication from yes to no and experimenting with that, but no luck.
I went to my linode dashboard and pasted my public key there too, but still it can't seem to find it.