September 2, 2014

How to set up SSH, using a Raspberry Pi as an example

SSH is a versatile and secure way of connecting to other devices, regardless of host/client operating system. Here's how it's done. I'll just use my Rasberry Pi as an example of how to do this, but these steps can be applied to any UNIX environment.

  1. See this article if for some reason SSH isn't already enabled on your Pi.
  2. Create your keys on your host machine if you haven't yet (see RSA vs DSA for key type info):
  3. mkdir ~/.ssh
    ssh-keygen -t rsa
  4. It's OK to use blank password defaults, unless you want the extra layer of security.
  5. Copy the public key to your Pi (replace the IP below with whatever your Pi's address is; use ifconfig on your Pi if needed to figure it out):
    scp ~/.ssh/id_rsa.pub pi@192.168.0.xx:~
  6. Connect to your Pi, being prompted still for your password one final time before kicking in your authentication keys:
    
    // SSH in from the host:
    ssh pi@192.168.0.xx
    // Enter your password, for the last time
    // Finally, pipe the SCP'ed public key into the authorized_keys file:
    cat ~/id_rsa.pub >> ~/.ssh/authorized_keys

Now you can log into your Pi from your host machine, securely, without being prompted for a password again.

No comments :

Post a Comment