Manage SSH keys on a Mac (OSX)

The generated key consists of a pair of files, one private and one public. It’s very important that you never share the private key, ever. While you will use the public key to authenticate with the external service.

Creating a key

To generate the key using the Terminal:

# Run the command below to generate an SSH key, then follow the prompts.
# Enter file location, or press enter to use the default location.
# Enter a passphrase, or press enter to for no passphrase. If you opt to use a passphrase you will need to enter it to use the key.

Now that the key can be copied to the clipboard ready for use:

pbcopy < ~/.ssh/

Removing a key

# Remove the private and public key, assuming the keys are in the default location
rm ~/.ssh/id_rsa && rm ~/.ssh/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.