/Teaching/Operating Systems/Tutorials/Git and SSH Setup

GIT and SSH Setup (for OS and SLP)

If you’re taking part in a course at IAIK you have to upload an ssh public key to the IAIK Gitlab in order to get access to your remote account. If you don’t have a ssh-keypair yet, or want to create a new one for use with your repository use (we assume you want to name your key sweb, feel free to find a better name):

ssh-keygen -t rsa -b 4096 -f ~/.ssh/sweb

And enter some passphrase (an empty passphrase is not recommended). You will then have the files sweband sweb.pub in the .ssh-directory in your home directory. The public key is the one with the extension .pub.

Please ensure the private key has file access modes 600 (change with chmod 600).

Now we will inform our ssh-agent about the new key:

 ssh-add ~/.ssh/sweb

In addition to that, you have to tell ssh, that it should use this particular key for the remote machine, by editing ~/.ssh/config and adding:

Host git.teaching.iaik.tugraz.at
  User git
  HostName git.teaching.iaik.tugraz.at
  IdentityFile ~/.ssh/sweb

Important: If the file ~/.ssh/config does not exist, create it first.

After you have uploaded the public key and set up your ~/.ssh/config, you can start using git.

Using git

It is strongly advised to make oneself familiar with git to be able to use it effectively. Especially the ease of branching and merging comes as a big aid when developing different features at the same time. Although this tutorial was not written to teach you how to use git, a few quick words are probably worth mentioning. We will assume that you have already installed git, either with your operating system’s packet manager or manually. To get the source code from the location described above, open a shell, go to the directory that you want to use as development directory and enter git clone git@git.teaching.iaik.tugraz.at:REPOSITORY_NAME.git .


This will then initialize a local copy of your remote repository in the current directory. Now you can start editing files to your heart’s content. When you want to commit your changes to the repository, type git commit -a. If you have added any new files, you will first have to add them to the repository with git add <filename> For more detailed usage of git, and how to restore older revisions, make branches, merge them, and so on, have a look on the internet, there is a multitude of git tutorials available. Two other, important things should be mentioned here, though.

First, you are required to configure git to use your real name and student e-mail address, so that you can be properly identified as the author of your commits. To do this, use git config --global user.name "Max Mustermann" && git config --global user.email "max@mustermann.com"


Upstream repositories are used to distribute patches, etc.

For “System Level Programming” you are expected to use this upstream repository: https://extgit.iaik.tugraz.at/slp/upstream.git

In case of SWEB development you will use the following upstream repository: https://github.com/IAIK/sweb.git
If there are any patches for SWEB bugs, they will be provided through the Github upstream repository.

You can create a new remote location for this repository: git remote add upstream <upstream URL>When you are done with that, you can pull the upstream patches into your repository withgit pull upstream main


As we recommend working in feature branches we want to show you one more command: git checkout -b my_feature This creates a new branch my_feature based on the current branch. Using the command git push origin my_featureyou can make your new branch available in your origin repository.

Next Chapter

Building SWEB (General/Linux)