Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Restore  SSH session after network breakdown (not using SCREEN)

Posted on 2007-04-10
14
Medium Priority
?
5,282 Views
Last Modified: 2008-01-09
This question bothers me for so long - is there any way to restore ssh (pts) session after client's disconnetion?

Here is an algorythm:
1. # ssh username@some.remotehost.com
2. open several interactive programms (mc, vim etc)
3. plug of network cable from client's computer :-)
4. open ssh connection from another computer and run:
    # who
    username   pts/3        Apr 10 14:04 (192.168.1.2)   <------ this session must be restored
    root    pts/6        Apr  2 11:04 (192.168.1.3)
    root    pts/7        Apr  5 15:39 (192.168.1.4)
    .....
5. huh? what to do?
0
Comment
Question by:OLEshiy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +3
14 Comments
 
LVL 34

Accepted Solution

by:
PsiCop earned 500 total points
ID: 18886168
No, because the cryptographic state has been broken.

If what you suggest were possible, then that would open SSH up to session hijacking, where an attacker impersonated the client of another session.

Security is balancing functionality/convenience with good defenses. You're looking for a convenience from a tool designed to provide good defenses.
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18886672
OLEshiy, hi.
I'm completely agree with PsiCop, you cannot connect to already dead session.
However _theoretical_ small possibility exists, on modified system.
OpenSSH uses openpty() library call (libutil) to allocate a pseudo terminal device. This call is implemented differently on different systems, but on Linux it opens '/dev/ptmx' and /dev/pts/* devices (by name) to find first free pseudo terminal. So, it's theoretically possible to fake /dev/ptmx and create a node with the same name, but your own pseudo terminal multiplexor driver with some  controlling process in a user space (much like screen). Then you may write program that can 'reconnect' such disconnected process and view the last screen. However you cannot fake 'ssh' to think that this tcp session is still alive (as correctly said by PsiCop) and any input will disconenect stale ssh session and kill your sshd.
0
 
LVL 5

Expert Comment

by:dr_shivan
ID: 18887124
Please enlighten me.

 I believe to have heard before that someone say that this is possible. On the server side you would have to make the TTL of the session to last longer and that the client has a fix ip. In order for SSH to work, you would require a 3 factor authentication which is the IP address, Application ID and also the SSL cert.

One can spoof the ID and maybe the Application ID but not the same cert right? The user will still need to relogin username and password to continue its session. I've seen it working but not the actual steps on how its being done. The reason behind it was that dial-up users which has slow connectivity find it a hassle if the connection drops half way and their password gets locked.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:Nopius
ID: 18887147
> dr_shivan
It seems you have missed some stuff from the original post

You say:
> On the server side you would have to make the TTL of the session to last longer *and that the client has a fix ip*

And what OLEshiy asked for:
> 4. open ssh connection from *another* computer and run:
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18887153
dr_shivan, really I tested such 'session restoration' what you are talking about, but from the same host (FreeBSD with some minor TCP tuning)
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 18887647
to restore/resume a session, you can use VNC or freenx (NX client).
VNC is packaged in most of Linux distribution.
freeNX and NX client you can download from
http://www.nomachine.com/download.php

Basically, those two tools allow you to resume/restore the remote terminal session, doesn't matter via telnet or SSH.
It allows you to resume/restore from other machine as well.
0
 

Author Comment

by:OLEshiy
ID: 18889428
Ok, let me paraphrase my question: is there any way to connect to existing pseudo-terminal (analogue to screen -x)?
As you've said above, every ssh-connection opens (or creates?) pseudo terminal. When netwotk connection breaks down, that pts remains alive for some time (according to such sshd configuration as "timeout", "keepalive" etc). I have root privelegies on the server.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 18891482
VNC or NX can fit your need just fine.
You can resume the VNC or NX session from any other machine if the network connection breaks down.
Those tools basically keep the session alive, unless you kill then or reboot, even thouth the network connection breaks down.
ssh or SSL for VNC or NX is used to encrypted the connection from client to server. After connection, it looks for the existing session first.
So you can easy to resume your session without deal with restoring ssh session.

I use NX/VNC at work and suspend it when I leave for home. Then resume the session at home when I need it.
0
 

Author Comment

by:OLEshiy
ID: 18896235
Thanks for all advices, but I still haven't heard an answer to my last question: is there any way to connect to existing pseudo-terminal?
0
 
LVL 27

Expert Comment

by:Nopius
ID: 18896606
> is there any way to connect to existing pseudo-terminal?
No.

 
0
 
LVL 27

Expert Comment

by:Nopius
ID: 19061418
sirbounty, hi.

The correct answer is here, was first suggested by PsiCop. There is _no_ possible way to connect to dead ssh session and it _is_ correct answer.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20294537
Forced accept.

Computer101
EE Admin
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question