SSH + Raspberry Pi
without a password
This is part of a short series of posts that i'm writing shortly after getting my hands on a Raspberry Pi In which i want to;
- SSH to it without a password.
- Make it a Print Server.
- Use it as a Git Server (coming soon).
- Install Node.js (coming soon).
- Host my website (coming soon).
Setting up your SSH keys
You can skip this section; Assuming you already have set up your SSH keys, in order to use something like Heroku or GitHub.If you haven't here’s a good article from GitHub.
Get your SSH key to the Pi
After setting you your SSH key (above) you should find that you have the following two files; ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub
These represent your public and private keys. We want to copy our public key (id_rsa.pub) in to a file called “authorized_keys” on the Raspberry Pi.
First, use secure copy or SCP to copy the file over.
$ scp ~/.ssh/id_rsa.pub pi@<ip address>:key.pub
Then, SSH into your Raspberry Pi.
$ ssh pi@<ip address>
If you don't have an .ssh directory (ls -a) then create it.
$ mkdir ~/.ssh
Append your public key to the file called “authorized_keys”.
$ cat key.pub >> .ssh/authorized_keys
Ensure that the owner can has read and write permissions.
$ chmod 600 .ssh/authorized_keys
And remove public key file that you initially copied over.
$ rm key.pub
Now you should be able to exit you ssh session and the next time you start it up, you wont have to enter your password.