I followed the instruction on Raspberry Pi website to generate SSH key pairs, towards the end of tutorial, it says once I have copied the id_rsa.pub key to the Pi's authorized_keys, it should use my public key next time I SSH into the Pi. However, on my Mac, it still asks for password when SSH to my Raspberry Pi. I have been looking for tutorial online, could not find any proper one that make it work using Mac's terminal. Could anyone please help me the set it up? Thank you.
Due to many people reported this question is unclear, let me clarify it by providing more details.
I did follow the tutorial on the Raspberry Pi for setting up passwordless SSH step by step. According to it, once the pub key has been copied over to RPi as authorized_keys, the RPi should automatically use it when I SSH to the RPi next time. However, it does not do it. How do I know? I have edited the sshd_config file to disable password login, enable the authorized_keys file location and tried SSH again, I got permission denied. By the way, I restarted the sshd service before trying SSH again.
After the first attempt, then I started searching on google, found another tutorial saying that I need to do the following: Open the sshd configuration file for editing with:
sudo vi /etc/ssh/sshd_config
…and add to the end of the file:
UsePAM no PermitRootLogin no AllowUsers pi RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys PasswordAuthentication yes
Tried, not working from Mac, however, it works on Windows PC using PuTTY, since PuTTY GUI allow you to specify where the private key is.
- I have not tried generate the key without passphrase yet. I will do it tonight and find out.
Additional question, if I have known_hosts on the Mac before generating SSH key pairs, would it be a problem? Do I have to delete it before generating the keys? Thank you.