Using ssh keys to log into your RPi is much more convenient than typing the password everytime.
It's especially handy if you want to log in from automated scripts or use programs such as scp or rsync
So how do I set up ssh keys to log into my RPi?
If you've never heard of ssh-keys before, you'll need to generate one like this
$ ssh-keygen -t dsa
This creates a directory
~/.ssh/ and stores the key files
$ ls -l .ssh/ -rw------- 1 gnibbler gnibbler 668 Aug 22 2004 .ssh/id_dsa -rw------- 1 gnibbler gnibbler 603 Aug 22 2004 .ssh/id_dsa.pub
You need to copy
id_dsa.pub to the RPi. There is a very easy way to do this using a helper script.
$ ssh-copy-id -i ~/.ssh/id_dsa.pub firstname.lastname@example.org
You'll need to type the
pi user password one last time
Next time you log in, you won't be prompted for a password
$ ssh email@example.com Linux raspberrypi 3.1.9+ #174 PREEMPT Sun Jul 22 19:04:28 BST 2012 armv6l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Type 'startx' to launch a graphical session
Once you have set up key-based logins, you don't need to log in using a password anymore; you can disable it, which is much more secure.
First, log in to your Raspberry Pi and open
root; for example, run
sudo vim /etc/ssh/sshd_config.
Find the line containing
PasswordAuthentication; it probably reads
Change this line so it reads
Restart your Raspberry Pi, or just
sshd on Arch, run
sudo rc.d restart sshd.
sshd on Debian based distributions, run
sudo /etc/init.d/sshd restart.