Page 1 of 1

losing SSH

Posted: Sat May 18, 2019 2:40 am
by josephchrzempiec
Hello i have a question I was working on something in SSH but one time i lost the ssh connection and don't remember where i left off and i had to start all over again. I thought i saw a way to go back in and pick up where i left off in the terminal something called screen not sure the name of it can someone please help me out? I try to search for it and all I'm coming up with is LCD and Led screens. So I'm typing something wrong.



Joseph

Re: losing SSH

Posted: Sat May 18, 2019 3:28 am
by tpyo kingg
That program would be GNU Screen. An easyshort cut is "screen -dR" which will connect to an old session if it is there or make a new session if there is none already running. "screen -ls" will show if you have any screen sessions running. You can maintain your connection with key-based authentication and a while loop, if it breaks such as may happen from a moving train or when you switch networks, say from home to school or work or a cafe.

Code: Select all

while ! ssh -t -i some.key.ed25519 -l pi xx.yy.zz.aa 'screen -dR'; do
        sleep 2;
done;
However, if you are just starting out, I'd recommend tmux instead. In many ways it is simpler to use. I moved from screen to tmux not so gradually for that reason.

Code: Select all

while ! ssh -t -i some.key.ed25519 -l pi xx.yy.zz.aa 'tmux attach-session || tmux new-session'; do
        sleep 2;
done;
There are a lot of guides and tutorials for both, but you can do a lot with just a small handful of options.

Re: losing SSH

Posted: Sat May 18, 2019 3:45 am
by josephchrzempiec
Hello thank you. I'm not sure how to install screen? Is there commands for it? That is what i'm having a hard time installing.

Re: losing SSH

Posted: Sat May 18, 2019 3:51 am
by tpyo kingg
Assuming the machine is headless, the generic answer is:

Code: Select all

sudo apt-get update;
sudo apt-get install tmux;
sudo apt-get install screen;
You can use either or both. Again, I'd recommend tmux. Read up on them a little and then try them.

Edit: along the same lines you can search for programs to install:

Code: Select all

apt-cache search screen;

Re: losing SSH

Posted: Sat May 18, 2019 3:54 am
by josephchrzempiec
Thank you.

I forgot to ask what is tmux?

Re: losing SSH

Posted: Sat May 18, 2019 4:27 am
by tpyo kingg
tmux is another terminal multiplexer, similar to screen. I have been a long time screen user but gravitated quickly to tmux after trying it out, thus multiple suggestions to take a look at it too.

Re: losing SSH

Posted: Sat May 18, 2019 9:55 am
by Andyroo
Have a look at https://m.youtube.com/watch?v=5iXzqN8-34E for a quick video on tmux.

Re: losing SSH

Posted: Sat May 18, 2019 10:23 am
by Donna25
Yes tmux can be useful in this case,it is almost same to screen..Try it once,u will not get disappointed myschoolbucks