I'm following this tutorial: http://www.codeproject.com/Tips/600050/Raspberry-Pi-SSH-Public-Key Pi -Authentication SSH Public Key Authentication
, but I'm generating the keys directly on my raspberryRaspberry.
So this is exactly what I did:
start a fresh raspibianRaspbian image
ssh-keygen -t rsa -C "my_name"
Saved at default folder /home/pi/.ssh
Copied the public key id_rsa.pubid_rsa.pub
to /home/pi/.ssh/authorized_keys
using the command:
cd /home/pi/.ssh
mkdir authorized_keys
cp id_rsa.pub authorized_keys/
so then I've gone to authorized_keysauthorized_keys
with
cp authorized_keys
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 piRaspberry Pi. It asks me to type the usseruser 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 methosmethods available (server sent: public key)
I've already formatedformatted my piPi 3 times and tried this with a fresh installation, but I'm getting these errors.
Could someone help me?
UPDATE:
When I try to log from the same raspberry pi, it says: Permission denied (public key).
When I see the permissions of the file "id_rsa.pub"id_rsa.pub
inside authorized_keysauthorized_keys
I get:
-rw-r--r-- 1 root root 387 Fevb 16 14:06 id_rsa.pub
is everything alright?
Update 2:
It looks like that authorized_keysauthorized_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
I think authorized_keysauthorized_keys
must be owned by pipi
, also?
UPDATE 3:
Changed group and user to pipi
and it worked. Thank you all.