Skip to content

Latest commit

 

History

History
106 lines (67 loc) · 3.08 KB

GitHubSSH.md

File metadata and controls

106 lines (67 loc) · 3.08 KB

GitHub Secure Shell

What is SSH?

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. wikipedia

In a nutshell, SSH protocol allows connecting to and authenticating remote servers and services. This protocol requires ssh keys which facilitates connecting to Github without providing username and password credentials.

Do I have existing SSH keys?

It is always good practice to look before you leap.

To check:

At the command line type the following:

    $ ls -al ~/.ssh

Note: DO NOT ENTER $ it simply signifies that you are at the command line.

The above lists the files in a directory named .ssh, if they exist. The following are default file names:

id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub

Keys to the kingdom

  1. Execute this command adding your Github email address to create a key pair:

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

  1. Press Enter to save the file to the default location when prompted. You have the option to save the file elsewhere.

  2. Type in a passphrase or opt out by leaving it empty when prompted.

  3. Confirm you passphrase.

Add keys via ssh-agent

  1. $ eval "$(ssh-agent -s)"

You should see something like:

Agent pid xxxxx

That starts a ssh-agent background process.

  1. If your OS is macOS Sierra 10.12.2 or later update your ~/.ssh/config file with the following:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa

See GitHub for more details.

  1. Add keys and store phrase to key chain.
$ ssh-add -K ~/.ssh/id_rsa

If you get an error see ssh-add:illegal option -K.

Add SSH key to GitHub

  1. View the contents of your public key.
$ cat ~/.ssh/id_rsa.pub
  1. Copy the entire key.

  2. Login in to GitHub.

  3. Click on you profile photo.

  4. Go to settings.

  5. In the left sidebar click SSH and GPG Keys.

  6. Choose New SSH key or Add SSH key.

  7. Use the Title field to name your key.

  8. Paste the key into the Key field.

  9. Click ADD SSH Key.

  10. Confirm your password if required.

You now have a secure SSH connection. You can forget about having to supply pesky username and password credentials.

WORTHY NOTE: The https protocol is less secure than SSH but, it is easier to configure and less likely to be blocked by a firewall or proxy. This means that the remote clone URLs work everywhere.

Resources

WIkipedia - Secure Shell

GitHub - Generate SSH Key

GitHub - option -K Error