How to use SSH & SSH public keys

Here’s a quick overview of SSH and SSH public keys and how to use them.

SSH (Secure Shell) is a way to log into a remote computer or server and “control” that server (i.e. run commands on it).

In order to “log in” to this remote server, you need an SSH public key – this key is used to verify that you should in fact be accessing the remote server. It’s like logging in with a username & password, but in a very secure way.

Note that you (i.e. your computer) must be given access to the remote server in order to access it (obviously). So an administrator either needs to give your computer’s SSH public key access to this server, or you need to use an SSH public key that you’ve been given by the administrator. No SSH public key, no access. This is why an admin over at WP Engine asks for your SSH public key when they’re setting up your application to work with git.

If you don’t have an SSH public key, you may need to generate one. To check if you have a key already, open up the command prompt (Terminal on Mac) and type this:

$ cd ~/.ssh

This checks to see if you have a directory named “.ssh,” and you would if you have any keys. If you have this directory, type this to list your SSH public keys:

$ ls

You can then copy one of your keys like this:

$ pbcopy < ~/.ssh/

If you don’t have any keys, then you can generate a new one. GitHub has some great instructions on generating SSH keys, and they explain it much better than I do.

Leave a Reply

Please login or fill out the form below to post a comment. Required fields NOT denoted by *