GIT and SSH Setup for Information Security
Creating an SSH Keypair
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 infosec, feel free to find a better name):
ssh-keygen -t ed25519 -f ~/.ssh/infosec
And enter some passphrase (an empty passphrase is not recommended). You will then have the files
infosec.pub in the .ssh-directory in your home directory. The public key is the one with the extension
Please ensure the private key has file access modes
600 (change with
Now we will inform our ssh-agent about the new key:
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/infosec
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.
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 email@example.com: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.
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 "Martina Musterstudent" git config --global user.email "firstname.lastname@example.org"
Upstream repositories are used to distribute patches, etc.
You will use the following upstream repository: https://extgit.iaik.tugraz.at/infosec/upstream.git
If there are any patches, they will be provided through the Github upstream repository.
You can create a new remote location for this repository:
git remote add upstream https://extgit.iaik.tugraz.at/infosec/upstream.gitWhen you are done with that, you can pull the upstream patches into your repository with
git pull upstream master
You have to tag your final submission for each assignment. This can be done with:
git tag <tagname> git push --tags