Internet Bandaid   [RSS Feed]

Archive for the ‘putty’ tag

SVN Access via SSH keys for Linux and Windows

with 4 comments

Many shared hosting packages offers only 1 SSH account, which can be a problem if you have many developers each needing his/her own unique credentials to access the server. This is especially the case if you have multiple developers needing to access a single subversion repository.

In this post, I outline the steps to offer a client machine (your developer) unique SSH credentials for server access via SSH keys. I follow up by showing how they can connect to your svn repository.

Step A: Setup on Client’s Linux Machine

// Performed by client (the developer)

If you use a unix-like OS, continue reading this step. If you use a Windows OS, skip this step and go to Step B.

1. Open up the terminal/shell.

2. On the command line, type:

ssh-keygen -t dsa

3. When prompted to enter file name, type:

mykeys

4. When prompted for a password, you can leave it blank and hit enter, or type in a password. Because we are authenticating via keys, it is not necessary to use a password.

5. Now you should have two files:

a) mykeys – the private key you keep to access the server
b) mykeys.pub – the public key you give to your systems administrator

6. Copy mykeys to the ~/.ssh directory.

7. Rename mykeys to id_dsa.

8. Give mykeys.pub to your systems administrator.

You are done. When your systems administrator installs the mykeys.pub on his end in Step C, you will be able to access his server via ssh using the new password you chose.

Step B: Setup on Client’s Windows Machine

// Performed by client (the developer)

If you use a windows OS, continue reading this step. If you use a unix-like OS, avoid this step and perform only Step A.

1. Go to http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html and download putty.exe and puttygen.exe.

2. Open puttygen.exe.

3. From the main menu, select Key>SSH-2 DSA key.

4. Press the Generate button.

5. Move your mouse cursor around to generate randomness as instructed by the program.

6. When key is generated, you may choose to fill in the keyphrase passes or leave them empty. Because we are authenticating via keys, it is not necessary to use a password.

7. Copy the contents in the “Public key for pasting into OPENSSH authorized_keys file:” into a text document. Save the text document as mykeys.pub.

8. Save private key as mykeys.ppk.

9. Send mykeys.pub to your systems administrator. Wait for him to configure things in Step C before continuing.

10. When your systems administrator is finished with Step C, you are ready to set up Putty SSH and SVN access. Open up Putty and fill out the Host Name.

11. In the Saved Session, type in a Session Name that you can easily remember. It will be used by svn later on.

12. On the left hand side, go to Connection>SSH>Auth and find the mykeys file for the private key field.

13. Go to Connection>SSH and make sure SSH 2 is selected.

14. Go back to the first Putty screen and save these settings.

15. Test the new SSH Key by clicking Open. Putty will prompt you for the private key password you chose earlier.

16. Download and install Tortoise SVN for Subversion access.

17. When Tortoise is installed, the path to your svn repository is

svn+ssh://username@sessionname/serverpathtorepository

The username is the ssh account username. The sessionname is the Session Name from step 11. This Session Name links back to the settings saved by Putty. When you log in, Tortoise will prompt you for your ssh key password.

You are done.

Step C: Setup on Unix-like Server

// Performed by systems administrator

1. Obtain the mykeys.pub from your client.

2. Copy the contents of mykeys.pub and append it to the file ~/.ssh/authorized_keys2 (if the file does not exist, create a blank document first and then append).

3. In the /pathtorepository/conf/passwd file, add a new username – password pair.

Your server is now ready to accept ssh access from your client. Repeat these steps for additional clients, and append the public keys to authorized_keys2.

Written by John Lai

February 13th, 2009 at 6:45 pm