User:Datagrok/Shorten your SVN+SSH url

From DreamHost
Jump to: navigation, search

Shorten the URL to your Subversion repository over ssh

Once you've set up your subversion repository on Dreamhost, your repository URL looks like this:

http://svn.hostname.com/project

If however you prefer the more secure svn-over-ssh access, by default you have to use a much longer URL:

svn+ssh://username@hostname.com/home/username/svn/project

But with a few additional configuration files, you can shorten that to:

svn+ssh://hn/project

Steps

1. Create a script that wraps svnserve with the default path to the repositories. Put in ~/bin/svnserve:

 #!/bin/sh
 /usr/bin/svnserve -r ~/svn/ "$@"

2. Make ~/bin/svnserve executable: chmod +x ~/bin/svnserve

3. Make sure that your ~/bin/svnserve is found in the PATH before the default/usr/bin/svnserve. Put into ~/.bashrc:

 export PATH=~/bin:$PATH

At this point, your repository URL for svn-over-ssh is

svn+ssh://username@hostname.com/project

You can further shorten this URL by configuring ssh to recognize a nickname for your host, and your preferred username there. On your (Unix) client machine, edit ~/.ssh/config:

 Host hn
   HostName hostname.com
   User username
Personal tools