how to keep an ssh session going despite constant disconnections?
June 5, 2008 10:23 AM Subscribe
How do you keep an SSH session alive when you are forced to use a crappy wireless network that constantly disconnects?
Every time my wireless connection disconnects, I have to log on again, delete the .swp file that vi creates when I disconnect, and reopen all the files that I had opened. Surely, there's a way to just restart exactly where I left off without having to do anything special?
I've tried searching Google for this, but every result has to do with keeping idle SSH sessions alive by using a keepalive ping, which is obviously not my problem. I'm using PuTTY, if that matters.
Every time my wireless connection disconnects, I have to log on again, delete the .swp file that vi creates when I disconnect, and reopen all the files that I had opened. Surely, there's a way to just restart exactly where I left off without having to do anything special?
I've tried searching Google for this, but every result has to do with keeping idle SSH sessions alive by using a keepalive ping, which is obviously not my problem. I'm using PuTTY, if that matters.
ssh host -t screen -xRe^oo will connect you to a persistent session, creating one if it doesn't exist, not knocking you off if you're connected from elsewhere.
I add the e^oo because screen's default command key is something really annoying.
posted by fantabulous timewaster at 10:45 AM on June 5, 2008 [2 favorites]
I add the e^oo because screen's default command key is something really annoying.
posted by fantabulous timewaster at 10:45 AM on June 5, 2008 [2 favorites]
Also, autossh. It would however mean moving away from PuTTY to openssh in cygwin.
posted by stereo at 11:11 AM on June 5, 2008
posted by stereo at 11:11 AM on June 5, 2008
screen screen screen screen screen screen screen screen
posted by thedaniel at 2:02 PM on June 5, 2008 [1 favorite]
posted by thedaniel at 2:02 PM on June 5, 2008 [1 favorite]
screeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeen.
aka: the best unix utility in the world.
posted by Project F at 2:23 PM on June 5, 2008
aka: the best unix utility in the world.
posted by Project F at 2:23 PM on June 5, 2008
As others have said; screen. It moves the persistent shell session to the remote server, and you just attach to that session. When your connection gets dropped, only the 'screen' client gets killed; your shell processes continue to run in the background until you reconnect.
To use fantabulous timewaster's suggestion, put the "screen -xRe^oo" in putty's Remote Command argument ("Connection->SSH-> Remote command"). I'd hold off doing this until you're familiar with screen. I'd also avoid remapping the command key with "e^oo" until you become more comfortable with screen, as most of the documentation will refer to the default Ctrl-A (which actually isn't bad if you remap Caps to function as a third Ctrl key)
The most basic way to use it would be to run screen immediately on the remote host, work as normal, then when you get disconnected, restart your ssh connection and run "screen -r", which should show you the most basic feature of screen.
screen will also disable putty's scroll-back by default. See: http://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-screen for a fix.
posted by theclaw at 2:38 PM on June 5, 2008 [1 favorite]
To use fantabulous timewaster's suggestion, put the "screen -xRe^oo" in putty's Remote Command argument ("Connection->SSH-> Remote command"). I'd hold off doing this until you're familiar with screen. I'd also avoid remapping the command key with "e^oo" until you become more comfortable with screen, as most of the documentation will refer to the default Ctrl-A (which actually isn't bad if you remap Caps to function as a third Ctrl key)
The most basic way to use it would be to run screen immediately on the remote host, work as normal, then when you get disconnected, restart your ssh connection and run "screen -r", which should show you the most basic feature of screen.
screen will also disable putty's scroll-back by default. See: http://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-screen for a fix.
posted by theclaw at 2:38 PM on June 5, 2008 [1 favorite]
YAPSTSITOS*
*(Yet another post suggesting that screen is the optimal solution.)
posted by dubitable at 5:35 PM on June 5, 2008
*(Yet another post suggesting that screen is the optimal solution.)
posted by dubitable at 5:35 PM on June 5, 2008
Always run long jobs in screen.
posted by PueExMachina at 5:50 PM on June 5, 2008
posted by PueExMachina at 5:50 PM on June 5, 2008
screen is a wonderful thing
posted by malaprohibita at 12:48 PM on June 8, 2008
posted by malaprohibita at 12:48 PM on June 8, 2008
« Older Will she end up with a crown or looking like a... | Recommendation for reporting tools for MySQL... Newer »
This thread is closed to new comments.
posted by TheNewWazoo at 10:35 AM on June 5, 2008 [6 favorites]