Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using upstart to keep a reverse ssh tunnel alive using auto ssh similar to Using Upstart to Manage AutoSSH Reverse Tunnel.

This works fine, except after a manual power down I can no longer connect to the machine through the "central server" using the tunnel. I receive "ssh_exchange_identification: Connection closed by remote host". The autossh process is running on the client. I can connect again after re-starting networking.

I'm trying to figure out why this is failing consistently after a manual shutdown. Is it possible that I need to do some cleanup on startup that would allow the tunnel to work in this situation, or are there some other debugging/troubleshooting steps I can take to determine the problem?

Machine A is the client machine, using autossh. This machine sits behind a firewall and uses the following command in upstart to create an ssh tunnel:

/usr/bin/autossh -fN -i /keyfile -o StrictHostKeyChecking=no -R 20098:localhost:22 user@centralserver

Machine B we'll call the "central server", which sits in the cloud and is the host. This machine is "centralserver" in the command above.

When Machine A is hard powered off, and back on, I cannot connect to it by SSH'ing from my machine (C) to Machine B in the cloud, then using the following command to get to Machine A:

ssh -p 2098 user@localhost

Again, after a reboot of the client (A), this works fine. It is only after a hard power down that the problem occurs. There are autossh processes that are running on the client machine (A) after powering down and back up, but they just don't seem to doing their job.

share|improve this question
    
Re-read your question. And rephrase it to understandable English. I can't figure out what you want and what your concrete problem is. –  mailq Aug 19 '11 at 15:10
    
I've rephrased the question @mailq, hopefully that makes more sense. –  grant Aug 19 '11 at 15:52
    
I still can't figure out what you do. You have machines A, B and C. Connect from where to where and reboot which one? And from where to where you can't connect afterwards? –  mailq Aug 19 '11 at 16:06
    
I've added some more detail @mailq, thanks for trying to help. –  grant Aug 19 '11 at 16:42

3 Answers 3

True, when clients with autossh running were not shutting down gracefully ssh instances still exist on the server. To resolve this try to kill these instances. I used killall -u and it works. After that, autossh reconnects to the server successfully and I can connect via ssh to the client. On the client where autossh runs, I have also set the parameter AUTOSSH_GATETIME=0.

share|improve this answer
up vote 0 down vote accepted

The problem was that the system was not shutting down gracefully. I installed acpid which adds a powerbtn.sh script in /etc/acpi that calls shutdown when the power button is pressed.

share|improve this answer

I found this tutorial useful and straight forward:

http://jiang925.com/content/tunnel-through-firewall-using-reverse-ssh-and-vpn-dd-wrt

they added the autossh command to /etc/rc.local so that it is executed at startup.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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