Linux Blog

Using Subversion with SSH & Custom Ports

Filed under: Linux Software,Quick Linux Tutorials — TheLinuxBlog.com at 9:09 am on Monday, September 15, 2008

Lets say you use subversion on your home PC to keep track of projects and you want to checkout or export your project from a remote location. Here’s the catch, sshd is running on a custom port or forwarded from another. For some reason the command line SVN client does not support a port parameter when using the defacto svn+ssh://

svn co svn+ssh://thelinuxblog.com/owen/svn/project1/trunk project1
ssh: connect to host thelinuxblog.com port 22: Connection refused

Well we know why the error above happens its because I happen to run SSH on port 1337. The following work around requires root privileges, and may mess with your system a bit but if you really need to check something out, then it will work.

As root, login and stop SSH if you run it. With SSH Forward port 22 with a local SSH forwarding connection to the remote host.

[owen@thelinuxblog.com]$ sudo su -
[root@thelinuxblog.com]$ /sbin/service sshd stop
[root@thelinuxblog.com]$ ssh -p 1337 owen@thelinuxblog.com-L 22:[internal ip]:1337

Once this is done, your localhost:22 now forwards to your remote host. With another session (on your local machine) you can verify the connection by using ssh localhost. You will probably get warnings about the hosts identity being changed, or not verifying it, but you can ignore then. Once you’ve tested it, just use SVN as normal. When finished, remember to logout of the SSH session, and start SSH back up again if you run it.





Random Man Pages:
xbattery
ppt
ppmqvga

2 Comments »

Comment by Michael Ben-Nes

November 26, 2008 @ 5:19 am

You can also add the following line to the subversion conf file, under the section: [tunnels] ( /etc/subversion/config in debian )

ssh8888 = $SVN_SSH ssh -p 8888 <- 8888 is the port

Then run the command:
svn+ssh8888 …. you know the rest

Comment by TheLinuxBlog.com

November 26, 2008 @ 10:54 am

Thankyou @Michael Ben-Nes

I’ve been meaning to find a way to do this for a while but just used my work around for the time being. Thats really helpful. Now, I wonder if it can be enabled per user.

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>