Skip to content

Latest commit

 

History

History
94 lines (60 loc) · 4.96 KB

2012-03-07-linux-verify-ssh.markdown

File metadata and controls

94 lines (60 loc) · 4.96 KB
layout title description
default
Verify Your SSH Keys
A quick guide to help you verify your SSH keys using fingerprints

This is the guide to verifying your SSH keys in Linux. There are also guides for Windows and OS X.

GitHub uses SSH keys to establish a secure connection between your computer and GitHub.

To verify your SSH keys you need to find the fingerprint of each key on your computer and compare it to the fingerprint displayed on GitHub.

If there are keys on your GitHub account that you don't recognize you should delete them immediately.

##First: What's a Fingerprint?

An SSH key's fingerprint is a sequence of bytes unique to that key. Fingerprints are usually encoded into hexadecimal strings and formatted into groups of characters for readability.

We display SSH key fingerprints on GitHub along with the key's title:

##Next: Find and Compare Fingerprints

First, you need to open an app called Terminal.

Open the terminal

Need a quick lesson about Terminal?

Code blocks like those on this page are part of a scripting language called Bash. To use Bash scripts, we need to use an application that comes with Linux called Terminal.

<h4>Input</h4>
<pre class="terminal bootcamp">
  <span class="codeline">$ echo 'This is input text'<span>This tooltip tells you what's going on.</span></span>
</pre>

<p>A line that begins with the dollar sign ($) indicates a line of Bash script you need to type. To enter it, type the text that follows the $, hitting the return key at the end of each line. You can hover your mouse over each line for an explanation of what the script is doing.</p>

<h4>Output</h4>
<pre class="terminal bootcamp">
  <span class="bash-output">This is output text.</span>
</pre>

<p>A line that does not begin with a $ is output text that is intended to give you information or tell you what to do next. We&rsquo;ve colored output text green in these bootcamp tutorials.</p>

<h4>User Specific Input</h4>
<pre class="terminal bootcamp">
  <span class="codeline">$ echo '<em>username</em>'<span>Outputs the text in the quotation marks.</span></span>
</pre>

<p>Areas of yellow text represent your own personal info, repos, etc. If it is part of an input ($) line, you should replace your it with your own info when you type it. If it is part of output text, it is just for your reference. It will automatically show your own info in Terminal.</p>

<p><strong>Good to know</strong>: There will be times when you type code, hit return, and all you are given is another prompt. Some actions that you execute in Terminal don&rsquo;t have any output. Don&rsquo;t worry, if there is ever a problem with your code, Terminal will let you know.</p>

<p><strong>Good to know</strong>: For security reasons, Terminal will not display what you type when entering passwords. Just type your password and hit the return key.</p>
  1. Find SSH key fingerprints.

    Copy and paste this command into Terminal to find the fingerprints for all public keys in your ".ssh" directory:

     for i in ~/.ssh/*.pub; do ssh-keygen -l -f "$i"; donePrint fingerprint for each public key in the ".ssh" directory in your user directory
     

    If the output says “No such file or directory“ then you have no SSH keys locally or they are stored somewhere else.

  2. Compare to fingerprints on GitHub.

    If you did not receive a “No such file or directory“ message then what you see should look something like this:

     $ for i in ~/.ssh/*.pub; do ssh-keygen -l -f "$i"; donePrint fingerprint for each public key in the ".ssh" directory in your user directory
     2048 c2:d1:0d:35:7f:b0:7d:44:c3:7d:7d:76:55:ff:99:7b /Users/chris/.ssh/github.pub (RSA)
    2048 b7:82:bf:e4:08:33:f9:45:b5:f5:40:cf:60:ab:47:51 /Users/chris/.ssh/staging.pub (RSA)

    The fingerprints are the hexadecimal strings, e.g. 22:d4:ab:9d:be:a9:4f:86:a2:05:45:88:0d:14:ea:e8.

    Now open https://github.com/settings/ssh and make sure the fingerprints attached to your GitHub account match the fingerprints in Terminal.

  3. Fingerprints don't match?

    If there are any SSH keys attached to your account that you don't recognize delete them immediately.

    If all the fingerprints match then you are safe - continue social coding.