Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resuming SSH session at another linux host 1

Status
Not open for further replies.

thedaver

IS-IT--Management
Jul 12, 2001
2,741
US
I'm having some problems with my local ADSL DHCP, the IP leases are expiring quite frequently and that's interrupting my SSH sessions to a number of remote hosts.

I have "server1" on a static IP outside of my ADSL LAN where I've now started to initiate the SSH terminal sessions to the other servers (2-n).

Is there a way, when my DHCP takes a new IP and I lose my SSH to server1, that I can SSH back in to server1 and resume one or more commands/SSH sessions that were originated from server1 to other servers2,3,4,n? I'm presuming that they'll stay alive for at least a few minutes until I can return....

Let's assume that I can find the PID of the SSH session I want to re-use (from server1->server2). What next?

Thanks!
D.

D.E.R. Management - IT Project Management Consulting
 
You would have to use some kind of virtual terminals. One option is to use a remote desktop via VNC, works well, but with all the overhead of using GUI of course.

I'm not sure whether you can use screen this way? I haven't used it much, but it might have the capability to reconnect to existing sessions.

Another possibility is... oh... what's it called... there's a tool that allows multiple people to share the same terminal session, used for training on Linux... umm... [ponder]

Annihilannic.
 
screen does a very good job at resumign a session that has been properly suspended (or detached, to use screent erminology) with the "screen -d" command.

I do not think it resomes sessions terminated abnormally.
I use screen exstensively but never tried that.

Will give it a bash and get back to you.


QatQat

Life is what happens when you are making other plans.
 
Yep, screen is the way to go.

After log in just run "screen" and you will be brought to your first virtual screen (screen:0)

To launch new ones

CTRL+A and C (not CTRL+A+C)

To navigate between virtual screens

CTRL+A and screen_number

Example to go to screen 3 (your forth virtual screen)

CTRL+A and 3

To get back to your original screen

CTRL+A and 0

To terminate a session correclty

CTRL+D

To Detach your session correctly and close your SSH connection

Code:
screen -d

/code]

If the connection drops you can resume all your screen sessions by reattaching them

[code]

screen -r


CHeers

QatQat




Life is what happens when you are making other plans.
 
kibitz is what I was trying to think of... thanks to one of my work colleagues for remembering.

Annihilannic.
 
GReat! Thanks Qat & Ani, that helps a great deal. If you could be as effective at getting AT&T DSL support to believe the problem is their's.... :)
Gracias!
D.


D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top