1

Our setup is as follows; - 2 tomcat servers hosting sites - 1 load balancer - SSH connection to client server which contains database

This approach has worked fine with the exception of one client where the SSH tunnel will not stay up consistently. Initially the SSH connection was dropping intermittently on the problematic server. To correct this I added ServerAliveInterval and ServerAliveCountMax as well as ClientAliveInterval and ClientAliveCountMax. The connection stayed up for a few days but then the customer's server crashed and the connection was dropped. This server crash was attributed to the SSH tunnel but I'm not certain this is the case. The tunnel.bat file was as follows;

:loop
ECHO OFF
echo y | plink.exe -ssh -R 24011:localhost:1433 connect@testsite1.fern.io -pw PasswordHereButI'mNotTelling
ping -n 10 -w 1 127.0.0.1>nul
REM ping -n 10 -w 1 127.0.0.1
goto loop

Changed loglevel to 3 and got the following output;

Jun 10 11:55:09 Phobos sshd[18092]: debug1: server_input_global_request: rtype tcpip-forward want_reply 1
Jun 10 11:55:09 Phobos sshd[18092]: debug1: server_input_global_request: tcpip-forward listen localhost port 24011
Jun 10 11:55:09 Phobos sshd[18092]: debug3: channel_setup_fwd_listener: type 11 wildcard 0 addr NULL
Jun 10 11:55:09 Phobos sshd[18092]: debug3: sock_set_v6only: set socket 8 IPV6_V6ONLY
Jun 10 11:55:09 Phobos sshd[18092]: debug1: Local forwarding listening on ::1 port 24011.
Jun 10 11:55:09 Phobos sshd[18092]: debug2: fd 8 setting O_NONBLOCK
Jun 10 11:55:09 Phobos sshd[18092]: debug3: fd 8 is O_NONBLOCK
Jun 10 11:55:09 Phobos sshd[18092]: debug1: channel 1: new [port listener]
Jun 10 11:55:09 Phobos sshd[18092]: debug1: Local forwarding listening on 127.0.0.1 port 24011.
Jun 10 11:55:09 Phobos sshd[18092]: debug2: fd 9 setting O_NONBLOCK
Jun 10 11:55:09 Phobos sshd[18092]: debug3: fd 9 is O_NONBLOCK
Jun 10 11:55:09 Phobos sshd[18092]: debug1: channel 2: new [port listener]

There's much more where this came from and will add more as requested but this block had the same id [18092] so thought it a good start. With my boss we then used C# to create the ssh connection. This again worked well but we immediately got a call to say the server had crashed again.

Could anyone please give me an indication as to whether the SSH tunnel was the cause of the server crash. I think there are a number of possible problems/reasons; - The server's memory is near peak (currently using 15 of 16GB) - netstat is showing connections in a close_wait etc state - conflict with sqlservr.exe using port 1433

I am having a complete nightmare with an SSH Tunnel. On and off we have been trying to rectify this problem for over three weeks and still no resolution so if anyone can help i will forever be in your debt.

1

I would seriously consider a dedicated VPN connection (either hardware or software) for this - a permanent SSH tunnel is extremely hacky and prone to failure/problems as you have found out.

However, if you really want to persue an SSH tunnel, you can use autossh to initiate the connection from a Linux server. I'm unsure if there are Windows builds available (your question mentioned a .exe so I assume Windows is part of your setup).

  • 1
    @Criag Watson Thanks for the info. I have seen references to using a VPN. This was the approach adopted before i started here so assumed it was the best. Will investigate using that or AutoSSH. Will keep you posted. Out of curiosity what issues could cause this? As i said every other client server SSH works fine with no problems at all whereas this one has been nothing but bother. – EamonnMcElroy Jun 11 '15 at 12:01
  • 1
    Using SSH with anything that pulls a lot of traffic has always been very hit-and-miss - SSH is a text-based console after all (Secure SHell). I would categorically say that an SSH tunnel for a database server is the wrong way to solve that problem. – Craig Watson Jun 11 '15 at 12:04

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.