P
P
paratrooper57302012-08-30 15:58:54
linux
paratrooper5730, 2012-08-30 15:58:54

how to reconnect to ssh session?

I connect to host 1 via ssh, from it I also connect via ssh to host 2. The first connection breaks, I reconnect to host 1. There, using ps -a, I see the ssh process. TTY is designated as pts/2. Can I somehow intercept this process and continue to work with host 2 in the same session?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
@
@sledopit, 2012-08-30
@paratrooper5730

How I love dialogues like:
- how to do X?
- if you did Y, then you would not need to do X.
There is reptyr:

Package: reptyr                          
New: yes
State: not installed
Version: 0.3-2
Priority: optional
Section: misc
Maintainer: Evan Broder <[email protected]>
Architecture: amd64
Uncompressed Size: 67.6 k
Depends: libc6 (>= 2.4)
Description: Tool for moving running programs between ptys
 reptyr is a utility for taking an existing running program and attaching it to a new terminal, and is particularly useful for moving a long-running process into a GNU
 screen session. 
 
 reptyr does a more thorough job of transferring programs than many other tools, including the popular "screenify" shell script, because it changes the program's
 controlling terminal. This means that actions such as window resizes and interrupts are sent to the process from the new terminal.
Homepage: https://github.com/nelhage/reptyr

He will do everything.
But, of course, it's better to take care of such things in advance and use screen in the future.

V
Vyacheslav Plisko, 2012-08-30
@AmdY

install the screen utility.
sovety.blogspot.com/2008/01/screen.html

S
Sergey, 2012-08-30
@Ualde

man screen

N
Next_Alex, 2012-08-30
@Next_Alex

I would advise not screen, but tmux .
Subjectively, it is more comfortable and more unpretentious.
And if you write in /etc/bashrc:

alias tmux='tmux attach || tmux new'
and in ~/.bashrc:
if ; then
    tmux
fi
then everything becomes very pleasant.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question