Fixing Bad SSH Connections?
Pilchie asks: "I often use SSH to access my computer at home, when I am either at work or at school. My problem is that I can't seem to make the connection persistent. I connect, and usually within about 30 minutes, all my Xterms are frozen, and I have to kill my SSH client and start again, which is annoying when I am coding something. My question is twofold. First, how to determine if it is something to do with SSH Client or Server, or whether it is my ISP's network which sucks? Second, Is there anything I can do about it?
"Here's a description of my system:
- Home machine: P166, 128MB RAM, running Debian Potato.
- SSH Server 1.2.27
- Remote Machine: PIII 450, 256MB RAM, running NT 4.0.
- SSH Client the windows one by Cedomir Igaly Rev 2.112, with Exceed as XServer
- Net connection: Cable Modem from Rogers@Home (Brampton Canada, near Toronto) (Note: It is one of the new Terayonones which doesn't have an IP address, uses DHCP and SNMP)
Lastly, two pieces of information that I think might be key. First, if I traceroute to my home machine just after the connection dies, I get to the gateway machine for my ISP subnet, but not to my machine. Second, when I used to do this from school a few months ago, on a Solaris 2.7 box, I would often have problems connecting, with the same thing happening with traceroute. However, once I got connected it usually worked fine.
Any ideas, anyone?"
I found that with ipmasq, my ssh connection would close unless I was in a program such as mutt or screen. I did further research and found this link which mentions that ipmasq connections will die after a timeout period. The solution (which I haven't actually tested, 'cause I'm almost always in mutt or screen) is to set a longer timeout.
I have expierence the exact same problem. My ssh sessions would time out if they were idle.
/bin/echo -e "300\c" > /proc/sys/net/ipv4/tcp_keepalive_time
/bin/echo -e "300\c"
My solution was just doing
That would increase the keepalive time, thus stop the disconnects. Ever since I've done that I've never had a problem again.
Depending on your version of bash you might not be able to do
You want 300 without a line break so you might have to do
/bin/echo "300\c"
This should help you and all others who have this problem.
echo -n "Adjust timer to prevent ssh and telnet session timeout" ipchains -M -S 144000 60 3600 echo "done"
I usually use joe, it updates the screen every minute because it has a clock in the title. Besides, having an editor open never hurts, right?
Since I do most of my work in screen, ^Ac joe has become a rather standard procedure for me.