14

I have configured SSH to be on port 20000. When I try:

svn co svn+ssh://server.com:20000/home/svn/proj1 proj1 --username jm

I get

svn: To better debug SSH connection problems, remove the -q option
from 'ssh' in the [tunnels] section of your Subversion configuration
file. svn: Network connection closed unexpectedly

I think I need to tell SVN to use port 20000 also?

I am on Ubuntu 11.10

18

You can define a new 'tunnel' in your Subversion configuration (~/.subversion/config). Find the section [tunnels] there and define something like:

[tunnels]
foo = ssh -p 20000

Afterwards you can contact your repository via the URL svn+foo://server.com/home/svn/proj1 proj1.

  • Also, if you want to override the default svn+ssh protocol's port, just define ssh = ssh -p 20000. This assumes you've modified /etc/ssh/sshd_config on the server so that Port 22 is replaced with Port 20000. – Cloud Sep 29 '13 at 18:01
  • 1
    @Dogbert: it doesn't work like you say: I tried ssh = ssh -p 20000 and then tried to checkout svn+ssh://example.org/var/svn-repos/mydev/trunk but this still tries on port 22 – rubo77 Jan 26 '15 at 16:15
13

Whenever you need to access an ssh server on a non-default port or with a different user name, you can define an alias in ~/.ssh/config.

Host mysvn
HostName server.com
Port 20000
User jm

Then run svn co svn+ssh://mysvn/home/svn/proj1.

3

If for some reason you could not edit the ~/.subversion/config file, then you can specify the port in the command-line:

svn co svn+ssh://joe@myserver/myrepo/ --config-option="config:tunnels:ssh=ssh -p 20000"

but you must do this option every time you run the svn command. This might make sense for a build agent.

0

In case your ~/.subversion/config file does not have ssh tunnel defined, you can override ssh command on per-call basis using SVN_SSH environment variable

SVN_SSH='ssh -p 20000' svn co svn+ssh://server.com/home/svn/proj1 proj1 --username jm

For example

deo@fox:~$ SVN_SSH='ssh -v -p 20000' svn ls svn+ssh://svn/
OpenSSH_7.9p1 Debian-10, OpenSSL 1.1.1c  28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to svn [192.168.177.2] port 20000.
debug1: connect to address 192.168.177.2 port 20000: Connection refused
ssh: connect to host svn port 20000: Connection refused
svn: E170013: Unable to connect to a repository at URL 'svn+ssh://svn'
svn: E210002: To better debug SSH connection problems, remove the -q option from 'ssh' in the [tunnels] section of your Subversion configuration file.
svn: E210002: Network connection closed unexpectedly

This won't work if your ~/.subversion/config file does define ssh tunnel, in that case config file takes precedence. (Which is rather unusual. Normally it's other way around, environment variables usually take precedence over config files)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.