Score:0

Linux server ssh connection wont authenticate my account using ssh key gen and prompts me for password

re flag

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.

Jaromanda X avatar
ru flag
have you done a verbose connection? `ssh -vvv ....etc` and inspected the output
HBruijn avatar
in flag
As a server admin you don't have to do your debugging and investigating only from the client side (with the afore mentioned increased verbosity flag `-v` for `ssh`) ; you also have access to the server side logs which will typically log the reason(s) why access gets denied or when the default [`LogLevel`](https://linux.die.net/man/5/sshd_config) doesn't tell you anything, increase the verbosity server side as well.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.