Ed Sabol
Ed Sabol

Reputation: 452

Can autossh be used to monitor "ssh -D" local dynamic port forwarding (SOCKS proxy)? If so, how? If not, alternatives?

When I'm teleworking, I need to access some internal web servers. I use ssh -f -N -D 4000 someserver.mywork.com on my home computer to setup local dynamic port forwarding. Then, I configure my web browser to use localhost port 4000 as a SOCKS host, and everything works great, even with HTTPS.

The problem is that the proxy stops working every couple of days. When this happens, the ssh process prints messages like the following:

accept: Too many open files

In this scenario, I have to kill the ssh process and restart it in order to get it working again. Based on my research into this error message, I could increase the limit on the number of open files, but that doesn't seem like a permanent or an ideal solution.

I was hoping autossh might be able to monitor the connection and restart it automatically. Is that possible?

I have tried the following command:

autossh -f -M 0 -N -D 4000 someserver.mywork.com

But it didn't work. The proxy stopped working, and autossh did not restart it. Any suggestions or alternative solutions to automatically restarting my ssh proxy?

Upvotes: 4

Views: 295

Answers (0)

Related Questions