I'm following this tutorial: Raspberry Pi - SSH Public Key Authentication, but I'm generating the keys directly on my Raspberry.
So this is exactly what I did:
start a fresh Raspbian image
ssh-keygen -t rsa -C "my_name"
Saved at default folder
Copied the public key
using the command:
cd /home/pi/.ssh mkdir authorized_keys cp id_rsa.pub authorized_keys/
so then I've gone to
and there was my public key in the format
ssh-rsa big_string_here my_name
then I copied the private key to my pen drive using
cp id_rsa /media/PENDRIVE
Opened puttygen, gone to Conversions, imported the key from my pen drive, saved the private key also in my pen drive, then opened Putty and started a connection to my Raspberry Pi. It asks me to type the user I want to connect, I type
pi and then the terminal writes this:
"server refused our key"
And gives the error:
Disconnected: No supported authentication methods available (server sent: public key)
I've already formatted my Pi 3 times and tried this with a fresh installation, but I'm getting these errors.
Could someone help me?
When I try to log from the same raspberry pi, it says: Permission denied (public key).
When I see the permissions of the file
authorized_keys I get:
-rw-r--r-- 1 root root 387 Fevb 16 14:06 id_rsa.pub
is everything alright?
It looks like that
authorized_keys is a file not a directory.
So I changed it to a file and now there are the permissions:
-rw------- 1 root root 387 Apr 25 18:44 authorized_keys -rw------- 1 pi pi 1766 ... id_rsa -rw-r--r-- 1 root root 387 ... ida_rsa.pub
authorized_keys must be owned by
Changed group and user to
pi and it worked. Thank you all.