I have a Raspberry pi 4 with a Linux OS & I am using a Macbook. The two machines are in the same LAN.
Raspberry pi IP address is 192.168.10.11
. I can ping the Raspberry Pi from my MacBook terminal successfully.
On my MacBook, I generated a ssh key pair under ~/.ssh/
, file names are raspberry
and raspberry.pub
.
In the terminal of my Macbook, I executed command:
ssh-copy-id -f -i raspberry.pub [email protected]
I verified that it successfully added the public key to the ~/.ssh/authorized_keys
file of the Raspberry Pi. And I verified it by login as a root
user in the Raspberry Pi.
Then, in a new terminal session of MacBook, I run ssh connection to the Raspberry pi:
ssh [email protected]
I thought it would not ask me password to login but I still get a password prompt asking for the root user password. And if I enter the correct password, I can login to Raspberry pie as a root user.
But why it asks password when making SSH login from my MacBook to the Raspberry Pi? I mean the public key is there under root user's ~/.ssh/authroized_keys
of the Pi. Where do I miss?
ssh -i ~/.ssh/raspberry [email protected]
id_rsa
I suppose.ssh-add ~/.ssh/raspberry
then the ssh connection could be established without specifying the private keyssh root@<IP of the PI>