fd Blog

Daniel Hilgarth on software development

Setting Up SSH Port Forwarding for Atlassian Stash

To setup SSH port forwarding for Atlassian Stash on Ubuntu, perform the following steps:

  1. Change default port for SSH access in the file /etc/ssh/sshd_config to something other than 22.
  2. Restart SSH:

     # sudo restart ssh
    
  3. Make sure to allow the new SSH port in the firewall
  4. Install haproxy:

     # sudo apt-get install haproxy
    
  5. Configure haproxy: Edit the file /etc/haproxy/haproxy.cfg and change its contents to:

     global
            daemon
            maxconn 10000
        
     defaults
            timeout connect 500s
            timeout client 5000s
            timeout server 1h
        
     frontend sshd
            bind *:22
            default_backend ssh
            timeout client 1h
        
     backend ssh
            mode tcp
            server localhost-stash-ssh 127.0.0.1:7999 check port 7999
    
  6. Edit /etc/default/haproxy and make sure it has ENABLED=1
  7. If haproxy doesn’t start at system boot, execute the following command. However, this shouldn’t be necessary, because the installer should already do this.

     # update-rc.d haproxy defaults
    

Atlassian Stash will now be available via SSH on the default SSH port 22.

Comments