Changing Port Number of svn+ssh Subversion Protocol
Most times, when we access subversion through the svn+ssh:// protocol, we are satisfied with the default behaviour, which is simply spawning ssh behind the scenes, and have it connect using the default port 22 of the ssh protocol.
But, sometimes this is not enough. In my previous post I just described how ssh is great for tunneling and port forwarding. To access a remote subversion server, which was hidden behind a firewall and two hops into the system behind it, I had to port forward a local port all the way to the ssh port 22 of the behind the firewall host. My local ssh port that was tunneled into the remote system ended up on a local port, say 12345.
So, how to tell subversion to spawn ssh with a config of port 12345, when accessing a svn+ssh://-like URL? Well, turned out to be quite easy.
Subversion has a local configuration file .subversion/config, which can be used for various, … hmm, configuration stuff
A cool thing is, that one can provide new protocols. So, with this configuration in .subversion/config:
[tunnels]
sshtunnel = ssh -p 12345
I can use a subversion URL like this: svn+sshtunnel:// and subversion will spawn the given command with the port option.
Great tool – subversion.
January 11, 2009
·
polesen ·
20 Comments
Tags: subversion · Posted in: Tools

20 Responses
agreed… svn++
Great! Works like a charm.
Thank you for suggestion!
Great post
I tried that with my hostgator account and it worked.
Thanks! this is helpful
Thanks!
It fixed my “svn: Network connection closed unexpectedly”.
Thanks, that’s what the answer I was looking for.
How about if I am using https to connect to the SVN repository?
I am trying something like that
// create remote port forwarding
ssh -R 7711:localhost:443 root@remote-server.com -p 222
// checkout from our server to the remote server
svn checkout https://localhost:7711/svn/trunk /home/code
But i get svn: Propfind of ‘/svn/trunk’: 405 Method not allowed (http://localhost:7711)
I am not sure about that. Haven’t done it with https.
Are you sure about -R. Shouldn’t that be -L ? If I understand you correctly, you have svn server at remote-server.com running on port 443, and want to check out from it locally on 7711? If that is so, I believe it should read “-L”.
So wheee do I put the configuration file? On the server or on the client?
On the client
Good tip! Another approach which may be easier is to just embed the port number into the URL, e.g.
svn+ssh://username@server.com:2222/some/directory
I don’t know whether all clients will be able to handle the port number in the URL in this format, but it works for mine. Putting the port number in the URL looks easier in general, but what I like about your approach is that it lets you change that port configuration in a central place, without having to touch any checked-out repositories. I can see this being handy if you’re in a situation where you have to mess around with your port tunneling situation frequently.
OK. Here’s how I fixed this (on Mac OS X, but fix should work on any client)
This particular issue arises when you are using a non-standard port (let’s say 12001 for sake of example) for your SSH server.
Apparently the SVN client experiences syntax errors when given a port address on a command line like this one:
svn list svn+ssh://username@domainname.com:12001/home/username/svn/myproject
So, to fix this, you need to create a client-side config file for SSH like this:
cd ~
cd .ssh
vi config (create a config file like the one that follows)
:w
:q
Config file located in ~/.ssh/config:
Host domain.com
User username
Port 12001
Then, issue your svn+ssh command WITHOUT the port like this:
svn list svn+ssh://username@domain.com/home/username/svn/myproject
That’s it!
Hope that helps.
Rick
@Rick,
THANKS!
The original fiddle with the subversion tunnel config didn’t work for me.
However, the SSH trick with the config file worked perfectly!
I was using the latest MacOSX 10.6
Kudos to you! It saved me a lot of hassle.
hi, sorry! I dont understand where is the configuration for tunnels, server or client?? thanks!!!!
@Leo
Locally/client. In $HOME/.subversion/config
@Rick
Thanks, I was able to specify the port through the SSH config.
If you get the message “Killed by signal 15.” whenever you use this it’s because you need the -q flag which svn normally has by default for svn+ssh.
sshtunnel = ssh -p 12345 -q
Accessing a remote svn repository on a non-standard port | SuperWebDeveloper.com - July 1, 2012
[...] http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/#12 Share and Enjoy: [...]
Using a Non-Standard Port With Subversion » A Moment of Wisdom - August 31, 2012
[...] Olsen of Denmark for being the blog where I finally found the answer to this problem. Reference: http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/ VN:F [1.9.20_1166]please wait…Rating: 0.0/10 (0 votes cast)VN:F [1.9.20_1166]Rating: 0 (from 0 [...]
SVN unter Linux nutzen - ascii_ch - March 13, 2013
[...] http://www.techper.net/2009/01/11/changing-port-number-of-svnssh-subversion-protocol/ Ähnliche BeiträgeTortoiseSVN Port ändern unter WindowsSSH als Proxy-ServerSSH Public-Key Authentifikation einrichten SVN unter Archlinux installierenSSH unter Archlinux installierenZemanta /* Tagged Linux, SSH, SVN, Versionsverwaltung. Bookmark the permalink. « yaourt unter Archlinux installieren Troubleshooting: yaourt Unable to open file: /usr/local/etc/pacman.conf » [...]
Leave a Reply