1
  1. I created the keys with ssh-keygen -t rsa -b 2048 and also tried ssh-keygen without arguments (which should be the same).
  2. The private key is in .ssh/id_rsa
  3. Its permissions are 600
  4. The .ssh directory permissions are 700
  5. It is not using a passphrase
  6. using -i <key file> has no effect.
  7. The remote server log makes no mention of a failing key. It just looks like a normal password login. This is why I think it must be local ssh not finding the key.

I'm at a loss. I can ssh in using keys from another box (a Windows box, using PuTTY), so I know it is working on the server. My local Linux is Mint, which is an Ubuntu derivative, but I doubt that has anything to do with anything.

  • I tried running ssh-agent, but that both did nothing (after telling me it was adding my identity), and also seems to only be for passworded key files, which mine isn't.

Here are the results of the ssh command ssh -l remoteusername -p 85 domain.com -vvv: https://pastebin.com/n2ef8qGv

That output is from a time when I didn't use -i. But the file I'm specifying is .ssh/id_rsa anyway, which is the same.


Solved. The problem was in the format of my authorized_keys file on the server. I had concatenated the two keys together because my searches said that was all the format was. But they need to be separated by a newline.

Because /var/log/auth.log said nothing about it, I assumed the problem couldn't be the server. Guess I was wrong about that. I know the last time I had ssh problems the log showed it. In fact just now I broke it on purpose and tried to log in, and the log has nothing about a failed key login. I got the message "server refused our key" locally, which is good, but there is nothing on the server in /var/log/auth.log or with journalctl _COMM=sshd.

  • Which user is the owner of the key file? Include ls -l key_file in the edit of your question. Try to change ownership of the key file with sudo chown user_name:user_name key_file. – kukulo Mar 14 '18 at 17:51
  • I don't think there is a "local" (i.e. client-side) log file by default - however you can output increasingly detailed connection logging information by invoking ssh with the -v or -vv or -vvv options – steeldriver Mar 14 '18 at 17:53
  • Are you trying from the same user? – NerdOfCode Mar 14 '18 at 17:56
  • @NerdOfCode no, it is a different user name than the user name on the remote machine. – felwithe Mar 14 '18 at 18:03
  • @kukulo yes I am the owner of both the directory and the file. – felwithe Mar 14 '18 at 18:04
-1

Copy the public key to the remote server home ~/.ssh/authorized_keys or use

ssh-copy-id remotehost
# or with specific key
ssh-copy-id -i ~/.ssh/id_rsa remotehost

which will do the copy for you.

If is is still not working, debug the ssh connection with

ssh -vvv remotehost

This will show, which keys and authentication methods are tried.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.