O'Reilly logo

Git for Teams by Emma Jane Hogbin Westby

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 -s)"

Register ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required