Configuring Subversion to Use SSH Tunnel Proxy for Faster SVN Operations


2 views

When working with Subversion (SVN) repositories through slow network connections, establishing an SSH tunnel can significantly improve performance. The basic SSH tunnel setup you've created with:

ssh -D 8090 user@ssh.proxy.net

creates a SOCKS proxy on localhost port 8090 that encrypts and routes all traffic through your proxy server.

Subversion can utilize this SOCKS proxy through several approaches:

Method 1: Using SVN Config File

Edit your Subversion configuration file (~/.subversion/servers on Unix-like systems):

[global]
http-proxy-host = localhost
http-proxy-port = 8090
http-proxy-username = 
http-proxy-password = 
http-compression = no

For SOCKS5 proxies specifically:

[global]
http-proxy-exceptions = *.yourdomain.com
http-proxy-host = localhost
http-proxy-port = 8090
http-proxy-type = socks5

Method 2: Environment Variables

You can set these environment variables before running SVN commands:

export SVN_SSH="ssh -o ProxyCommand='nc -x localhost:8090 %h %p'"
export http_proxy=socks5://localhost:8090
export https_proxy=socks5://localhost:8090

Method 3: Command Line Parameters

For individual SVN operations, you can specify:

svn --config-option servers:global:http-proxy-host=localhost \
    --config-option servers:global:http-proxy-port=8090 \
    checkout http://svn.example.com/repo

For repositories using svn+ssh protocol, modify your SSH config (~/.ssh/config):

Host svn-server
    HostName svn.example.com
    ProxyCommand nc -x localhost:8090 %h %p
    User yourusername

Then access your repository with:

svn checkout svn+ssh://svn-server/path/to/repo
  • Verify the SSH tunnel is active: netstat -tulnp | grep 8090
  • Test proxy connectivity: curl --socks5 localhost:8090 http://example.com
  • Enable SVN debug logging: svn --username youruser --password yourpass --config-option config:miscellany:use-commit-times=yes --config-option servers:global:http-proxy-host=localhost --config-option servers:global:http-proxy-port=8090 --verbose checkout http://svn.example.com/repo

When using SOCKS proxies with SVN:

  • Disable HTTP compression (as shown in config examples) as the SSH tunnel already compresses data
  • Consider using -C flag with SSH for additional compression: ssh -C -D 8090 user@ssh.proxy.net
  • For large repositories, batch operations might timeout - adjust SVN timeout settings

When working with SVN repositories through slow network connections, establishing an SSH tunnel proxy can significantly improve performance. The basic command for creating a SOCKS proxy through SSH is:

ssh -D 8090 user@ssh.proxy.net

This creates a SOCKS5 proxy on localhost port 8090 that routes all traffic through your SSH server.

Subversion can leverage this proxy tunnel through either system-wide or repository-specific configurations:

Global Configuration (affects all repositories)

Edit your Subversion servers configuration file (typically found at ~/.subversion/servers on Unix-like systems):

[global]
http-proxy-host = localhost
http-proxy-port = 8090
http-proxy-username = yourproxyusername
http-proxy-password = yourproxypassword
http-proxy-exceptions = *.local,localhost,127.0.0.1

Repository-Specific Configuration

For individual repositories, you can modify the svnserve.conf file:

[general]
use-proxy = yes
proxy-host = localhost
proxy-port = 8090

For direct svn+ssh connections, you can configure SSH to use your proxy:

Host svn-repo.example.com
  ProxyCommand nc -X 5 -x localhost:8090 %h %p

Check if your proxy is working by running:

svn info https://your.repository.url

Monitor the SSH tunnel connection to confirm traffic is flowing through your proxy.

  • Ensure your SSH tunnel remains active (consider using autossh for persistent connections)
  • Verify firewall settings allow connections to localhost:8090
  • Check SSH server configuration permits port forwarding

For large repositories, consider these optimizations:

svn checkout --depth=immediates https://repo.url
svn update --set-depth=infinity subdirectory