Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Generating SSH keys

Martijn Steenbergen edited this page Apr 26, 2017 · 14 revisions

This manual is largely based on the Generating SSH keys Github page.

For the course you will need to work with Git. To identify you with the Git server, you should set up an SSH key.The steps below will walk you through generating an SSH key and adding the public key to your DevHub account.

Step 1: Get the tools

You will need to install Git. Follow the steps below for your operating system. You are allowed to use other Git clients for the labwork, but we will not help you to set up Git for these clients.

Windows

Please install Git Bash. If you want to use Powershell instead of Mingw, it is recommended to install with the Powershell extensions enabled, so the commands used in this manual will work on your terminal.

OSX

Git is included in the XCode Command Line Tools. Open a terminal and run git to see if Git is installed. If not, the system will prompt you to install Git.

Linux

Open a terminal and install Git using the package manager of your preference, for example: apt-get install git.

Step 2: Check for SSH keys

Open a terminal (we highly recommmend Git Bash for windows) and run the following command:

ls -l ~/.ssh

If you get an error: No such file or directory continue with the steps
If the directory contains a file named id_rsa.pub you do not have to set up a new SSH key and you can go to step 3.

Generating SSH keys

Open a terminal and run the following commands:

ssh-keygen -t rsa -C "<your_name>@student.tudelft.nl"

And press "Enter" 3 times, as we want to use the standard name without a password

Turn on your on ssh-agent:

eval `ssh-agent -s` # Windows (Git Bash) (make sure you use ` characters)
eval $(ssh-agent -s) # Linux, Mac or Windows with (msysgit)

Add your generated SSH key to the ssh-agent:

ssh-add ~/.ssh/id_rsa

If you get the error "Could not open a connection to your authentication agent", you a have to enable it. (See above)

Step 3: Add SSH key to Devhub

Copy the file contents of the public key to the clipboard:

clip < ~/.ssh/id_rsa.pub # Windows
pbcopy < ~/.ssh/id_rsa.pub # OSX 
sudo apt-get install xclip && xclip -sel clip < ~/.ssh/id_rsa.pub # Linux
  • Login to Devhub and click go To Account.
  • Click Setup new SSH key.
  • Give the SSH key a name, for example: My Laptop
  • Paste the key contents to the public SSH key field NOTE do not add spaces or new lines to the content*
  • Click Add SSH key

Step 4: Configure Git

Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. The first thing you should do when you install Git is to set your user name and e-mail address. This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating.

git config --global user.name "<your name>"
git config --global user.email <your_name>@student.tudelft.nl

Step 5: Clone the repository

  • Go to Courses and click the current course
  • Copy the Git clone url from the page and execute it in the terminal. It will look something like this: git clone ssh://[email protected]/courses/ti1706/1617/group-<Your group number>
  • If you get a connection time out, you probably did one or more of the steps above wrong.
  • If it asks you for a password, you probably did one or more of the steps above wrong.
  • WARNING: If you try to clone incorrectly more than 5 times, you will be blocked for an hour

Step 6 (Optional): Adding the project to SourceTree

  • Click Clone / New in SourceTree
  • Click Add Working Copy and add the repository via ...
  • Click Options under the Tools tab (Top bar) in SourceTree
  • Under SSH Client Configurations the SSH Client is probably: PuTTY / Plink. Change this to OpenSSH (This step is not needed on mac)
  • The field above should probably have changed to the correct rsa key. If you decided to change the name of the rsa key, you should change it to the correct key.
  • Good luck!

Step 7 (Optional): Automatically import your credentials when opening git bash (Only for Windows)

  • Open Git Bash
  • Run the following command:
  printf "eval \`ssh-agent -s\`\nssh-add ~/.ssh/id_rsa" >> ~/.bashrc