Close

Sending your public key

A project log for SSH Keys for Raspberry Pi

How to set up your raspberry pi to use SSH keys and disable password logins.

lazLaz 05/12/2015 at 21:190 Comments

So, now that you have a pair of keys on your computer, you need to get the key to your raspberry pi. There are a few ways that you can do this. You can SSH into the machine and append your public key to its authorized_keys file, but that's complicated. You can use the command "ssh-copy-id" to send your public key over ssh to the right location automatically.

ssh-copy-id pi@<RPI.IPADDRESS>
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
pi@<RPI.IPADDRESS>'s password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'pi@<RPI.IPADDRESS>'"
and check to make sure that only the key(s) you wanted were added.
It's that easy. It even prompts you how to check to make sure it works. When you follow the recommendations, you will not be asked for the user pi's password. Instead, if you set up your ssh keys with a passphrase (and you should), you'll be prompted to enter that. Once you enter your passphrase, you'll be able to log in directly, with no need to remember a password for the raspberry pi (because it really, really shouldn't be "raspberry").

So now that you can authenticate without using a password, it's time to configure SSH on the raspberry pi to disallow connecting with a password at all.

Discussions