Generate an SSH key pair

SSH is the secure shell program for connecting to remote servers. It’s also used as a transport mechanism for Git and many other tools. Part of how SSH works is based on public key cryptography, in which you have a private key accessible only to you, and a corresponding public key that you can share with anyone.

Warning: If anything doesn’t work as shown, please get in touch with the professor right away with the details. Precise output, error messages and screen-shots will help us diagnose the problem!
  1. Inside your debian-liucs virtual machine, open a terminal window.

  2. At the terminal prompt ($), type the following command and press enter:

    ssh-keygen

    It should produce output like the following. You will have to press enter three more times (shown as ⏎ below): once to use the default file name, and twice to enter an empty passphrase. Your fingerprint, ID, and “randomart” will differ from mine, of course.

    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/liucs/.ssh/id_rsa): ⏎
    Created directory '/home/liucs/.ssh'.
    Enter passphrase (empty for no passphrase): ⏎
    Enter same passphrase again: ⏎
    Your identification has been saved in /home/liucs/.ssh/id_rsa.
    Your public key has been saved in /home/liucs/.ssh/id_rsa.pub.
    The key fingerprint is:
    a9:84:3a:69:07:8d:2f:94:0e:4a:f6:27:62:b8:04:ad liucs@liucs
    The key's randomart image is:
    +--[ RSA 2048]----+
    |                 |
    |                 |
    |                 |
    | . + .   .       |
    |oo* o . S        |
    |*=.= . .         |
    |E+Boo..          |
    |oo.+o            |
    |.                |
    +-----------------+
    liucs@liucs:~$ 
  3. Your public key is now in the file ~/.ssh/id_rsa.pub. To find it, open the file manager.

    Files and directories that start with a dot are hidden by default. From the View menu, select Show Hidden Files. Then double-click the .ssh folder.

  4. When you double-click the id_rsa.pub file, it will open in medit, the default text editor.

    Depending on your course or project, you may have to submit this public key. It is one very long line. Use control-A (or Edit » Select All) and then copy and paste wherever it is needed.

    Note: If you have trouble copying and pasting from the virtual machine to your host machine, you can instead open a browser within the Virtual Machine. Then copy and paste between medit and the browser should work.
    • If we are using my git@liucs.net server, just paste the key into an email to me, along with your name.

    • If we are using GitHub, log in to https://github.com/ in your browser and select Account Settings in the upper right. Then, in the section SSH Keys, you’ll find a button Add SSH key. Paste your public key into the Key section, and give it whatever title you want. Push the green button to accept.