views:

283

answers:

7

It's inconvenient to lose code just because ssh decided to drop my connection. How can I avoid that? What if I'm forwarding an X11 connection over the connection?

+12  A: 

Use screen.

chaos
Didn't this work?
Georg
Screen won't help with forwarded X connections.
Andrew Medico
I think some programs can re-connect ( or change connections) to an X server, but most X clients don't like it when the server disappears. So make the server live on the same system as the client. To accomplish that, use VNC.
Rob Kennedy
+1  A: 

I have used NoMachine with good success.

David Segonds
I've never heard of that before just now. Can you elaborate, please? What does it do over and above what Screen and VNC do?
Rob Kennedy
NoMachine is like screen for X11 connections, and unlike vlc it is fast enough that a tabbed remote gnome-terminal session is an adequate substitute for plain ssh.
joeforker
+6  A: 

For a resumable GUI connection, you could use VNC.

Andrew Medico
+1  A: 

1/ use screen

2/ run non-interactive commands: nohup command &

Then do tail -f nohup.out to see the output of the command

Julien
+1  A: 

These "resilient connections" modifications to ssh might be of interest (I haven't tried them myself; I use VNC over ssh). Their paper is worth a read too.

timday
A: 

Use screen. Once you've installed it, open the screen program. It should behave like a regular shell.

if you get disconnected, run the following to reconnect.

screen -d -r

If you want to detach without having to have been disconnected, Hit CTRL+A, then D

A: 

Another vote from me for screen. Some useful commands:

Start screen and give the session a name:

screen -S MySession

During your session you can disconnect using "Ctrl-A d". Later you can reconnect to the session using:

screen -d -r MySession

Some useful keyboard shortcuts:

  • Ctrl-A c = create a new window in the session
  • Ctrl-A n = cycle to the next window in the session
  • Ctrl-A S = split the console to show 2 regions (Ctrl-A TAB to switch from top to bottom region)
  • Ctrl-A X = remove the current region (does not close the window - just "un-splits" the console by removing a region)
KarstenF