Table of Contents
Setting up SSH for SVN Repositories
This is a tutorial on how to set up the public key infrastructure to access SVN repos from svn.ai.uni-bremen.de
.
The basic idea is that we generate a pair of keys - private and public - the public key we give away and the private one should always be safely stored in our system.
Keep in mind that authentication will only succeed if the SVN server has your public key. Usually, you can just send the file to our system administrator.
We assume that the URL of the repo that we want to connect to is ssh+svn//svn@svn.ai.uni-bremen.de/reponame, where reponame
will be different for each repo.
Linux
In Linux the keys are usually stored in ~/.ssh
, the private key is per default named id_rsa
and the public one id_rsa.pub
.
- So, first make sure we do not have a pair of keys already existing:
$ ls ~/.rsa
- Then we install a SSH client if we do not have it yet:
$ sudo apt-get install openssh-client
- Finally, we generate the key pair:
$ ssh-keygen -t rsa
The password is optional. For more information on generating keys use
ssh-keygen –help
orman ssh-keygen
. - Now we can check out the repo:
svn co svn+ssh://svn@svn.ai.uni-bremen.de/reponame
Windows
Step 1
In Windows we will need the following two programms: PuTTY and Tortoise-SVN. the official download pages are http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and http://tortoisesvn.net/downloads.de.html. The easiest way to get all the parts of PuTTY we need is to use the installer from the download page (version can be different):
Step 2
Now we have to create a pair of keys. Launch PuTTYgen which was installed with the PuTTY-installer (default location: C:\Programm Files (x86)/PuTTY/
). We can leave the settings as they are and click on generate.
Keep moving the mouse in the blank area until the progress bar is full.
Now we create a folder in our user directory with the name ssh
.
In this folder we save the public key as id_rsa.pub
and the private key as id_rsa.ppk
.
IMPORTANT: Please send the full text (beginning with ssh-rsa…) below “Public key for pasting into OpenSSH authorized_keys file:” to our sysadmins: agkiadm@cs.uni-bremen.de
Step 3
After that we create a shortcut on the Desktop of the pageant.exe which should be in the same folder as the PuTTYgen.exe (by default: C:\Programm Files (x86)/PuTTY/
). Right-click the shortcut and open the Properties
. There in the end of the target line add “$PATH/ssh/id_rsa.ppk”
(replace $PATH with the path to your user directory). Don't forget the double quotes!
Next we can move the shortcut we just created to our startup folder (Autostart on german Windows) in the startmenu. Note: If you don't want to add pageant to your startup folder, please make sure that you've started pageant with the desktop shortcut created BEFORE interacting with SVN. This has to be done once everytime after you reboot your machine. Note 2: If you are using Win10 or higher, you have to access your autostart folder differently. Hit the WIN Key and R at the same time. In the new dialog enter shell:startup and hit enter. A new explorer window appears. Place the shortcut in that folder.
Now restart your PC. If you set a passphrase for your key you have to type it in from now on when you boot your PC.
If not there will only be a symbol in your taskbar.
Next we use PuTTY to configure a SSH connection (should be in the same directory as pageant and PuTTYgen). Under Session we specify the username and the hostname of the SVN repository. Enter “svn” below “Saved sessions” to give this configuration a name and press on “Save”. After saving the session configuration, press on “open” to connect to the SVN.
Log in using the username svn
. If the server has our public key this should be successful and will show an output similar to this:
X11 forwarding request failed on channel 0 PTY allocation request failed on channel 0 ( success ( 2 2 ( ) ( edit-pipeline svndiff1 absent-entries commit-revprops depth log-revprops partial-replay ) ) )
Step 4
After we configured pageant in step 3 we are now ready to checkout an SVN-repository. To do that we open an explorer and go to the directory where the reporitory should be placed. Then we right-click in the windows and click on SVN Checkout…
Now we pass in the URL where the repository is located. The structure of an URL for a checkout with SVN and SSH should be like this: svn+ssh://"Loginname"@"Server-URL(IP)"/"path to the repository"
i.e. svn+ssh://svn@svn.ai.uni-bremen.de/repoName
.
If you want you can change the Checkout directory (directory where the Repository will be placed) and after that we just click on ok and the Repository will be downloaded.