1

I am trying to set up the SSH configs on my Raspberry Pi at home so that I can login to it from wherever I want using PuTTY on Windows. I am a beginner and I barely understand what I am doing right now. I've been searching online and on Stack Overflow for too long now that I'm becoming desperate.

I have tried some of the solutions and probably did not understand why or how. I'm not sure now if my settings are fine or completely messed up. Some were talking about changing some configs in certain files, but there were some differences between their files content and mines or they weren't in the same directory, and more..

I have followed this answer but it did not solve my problem.

My issue is that upon login in my raspberry account using PuTTY, I get the error Server refused our key. I can log in using the account's username and password but I wish to connect with ssh for when I'll be connecting from outside my home network. I'll be deactivating the password authentication later on.


PuTTY on Windows 10

  • I have generated a private and a public key with PuTTYgen.
  • Under Connection > SSH > Auth, I have selected the generated private key.

Raspberry Pi

  • SSH server is Enabled
  • I have set chmod 700 to ~/.ssh
  • I have created a file named authorized_keys (in ~/.ssh) with chmod 600
  • I added the public key generated with Puttygen on Windows in the file

---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20191214" AAAAB3NzaC1yc2EAAAABJQAAAQEAjB+OgsqvCXfartVEiAYm/FDeda2tVuZb1p72KCRhk621uzknoMGlsl8ImxueM/52txPOji5qdQcTlZMAE+SUVGCp+zo+RIjwM/XYL/3aRJ5OQtDkuVEx+auGddlLy71JhfPZ1ItgaaiQzKeqvMpOa9fXiKHjJI3GBhJ0nKbZbMdHgIlkNS+8cq7/k/bw37aHOjkfXgktYYkopD/DBHbKFHtzmzko/dpjrCAuYXRsB/7L2drKNFV+C1qfBpWuHX70xXbch8tUW7cfTBjtCUrGvcydApJKqhuaIjBKd/J7uZyeiu4uSwOG2a/rIqzIX60O6c/QwXk3w2sTvISUFg8AGw==
---- END SSH2 PUBLIC KEY ----

I read that it should be inline and in the format ssh-rsa [pub.key]== some@user so I wrote this :

ssh-rsa  AAAAB3NzaC1yc2EAAAABJQAAAQEAjB+OgsqvCXfartVEiAYm/FDeda2tVuZb1p72KCRhk621uzknoMGlsl8ImxueM/52txPOji5qdQcTlZMAE+SUVGCp+zo+RIjwM/XYL/3aRJ5OQtDkuVEx+auGddlLy71JhfPZ1ItgaaiQzKeqvMpOa9fXiKHjJI3GBhJ0nKbZbMdHgIlkNS+8cq7/k/bw37aHOjkfXgktYYkopD/DBHbKFHtzmzko/dpjrCAuYXRsB/7L2drKNFV+C1qfBpWuHX70xXbch8tUW7cfTBjtCUrGvcydApJKqhuaIjBKd/J7uZyeiu4uSwOG2a/rIqzIX60O6c/QwXk3w2sTvISUFg8AGw== pi@raspb

Do I have to edit anything in the ssh_config and sshd_config files for it to work?

pensum
  • 123

1 Answers1

0

With the help of a user that unfortunately deleted his answer, I double checked in ~/.ssh/authorized_keys and noticed that by changing the format of my public key by hand, I had written an extra space between ssh-rsa [mypublickey]==

Also, he mentioned that the text following == was irrelevant since it is basically a comment that was created when generating the key with PuTTYgen.


Concerning the ssh_config and sshd_config files, I did not need to edit them at all but if you have to check what are the settings for your server, you need to go in sshd_config. This is where you should read the following : # AuthorizedKeysFile .ssh/authorized_keys
pensum
  • 123