Appendix D. SSH Keys

SSH keys allow you to make a connection to a remote machine without having to enter a password every time. The keys themselves come in pairs: a public-facing key and a private key. The private key should be treated like a password, and never shared with anyone. The public-facing key will be “installed” elsewhere, such as a code hosting system.

Create Your Own SSH Keys

To create an SSH key, you will need to run a program, which will save a pair of files. The necessary software is already installed on *nix-based systems, but Windows users will need to download additional (free) software.

Linux, OS X, and Unix-variants

To generate a key pair, run the following command:

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

You will be prompted for the following information:

File location

Accept the default location by pressing Return to continue.

Password

It’s optional, but you really should have one. Make it memorable or store it in a very secure password keeper that you use regularly.

The fingerprint for your key will be printed to the screen, and the key pair will be saved to the appropriate location in ~/.ssh/.

You will now need to register this key with your system so that you can begin using it.

This is where things get a little secret agent. You need to register your keys with the local “agent” (using OS X? think “keychain,” but different). Begin the ssh-agent application and redirect it to use a Bourne shell:

$ eval "$(ssh-agent ...

Get Git for Teams now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.