Jump to content

Resume Ssh Session On Physical System


vdub

Recommended Posts

This may be a really stupid question but I searched Google and could not find a way to do it.

I know you can suspend sessions with Ctrl_s and resume with Ctrl_q but lets assume that I am away from my shop and I ssh in to run a command. I want to allow this command to continue running on the remote system when I exit ssh, so I don't want to suspend the session. However, I want to resume that ssh session in a terminal later on the physical system. Is that possible?

Edited by vdub
Link to comment
Share on other sites

Look into a program called "screen"

Debian: apt-get install screen

You know I saw that but for some reason thought that it was meant for individual commands. I want to be able to restore the entire session. I will read the man page and play around with it.

Thanks.

Link to comment
Share on other sites

Screen is what you want. Should be installed on Ubuntu and Ubuntu server by default (if not sudo apt-get install screen).

screen = Create new screen session

CTRL-ALT-D = Detach session

Then you can close the SSH session or let it die.

SSH back in when you want to regain axx and type "screen -ls" and locate your session.

Then type "screen -r sessionname" and viola.

Link to comment
Share on other sites

Screen is what you want. Should be installed on Ubuntu and Ubuntu server by default (if not sudo apt-get install screen).

screen = Create new screen session

CTRL-ALT-D = Detach session

Then you can close the SSH session or let it die.

SSH back in when you want to regain axx and type "screen -ls" and locate your session.

Then type "screen -r sessionname" and viola.

That works great, thanks

However, Its Ctrl+a+d to detach.

It would be nice if you could tab complete the session name rather then typing it in but the plus side is if you only have one detached session you only have to type screen -r to attach to it.

Link to comment
Share on other sites

That works great, thanks

However, Its Ctrl+a+d to detach.

It would be nice if you could tab complete the session name rather then typing it in but the plus side is if you only have one detached session you only have to type screen -r to attach to it.

You can highlight the name and middle-click to copy it. Or when you create the Screen session you can name it with 'screen -S <name>' and then resume it with 'screen -r <name>'.

Link to comment
Share on other sites

Look into screen or tmux. I have this alias in my ~/.bash_aliases for when I connect and want to re-attach:

alias screenr="screen -raAd"

I will have to look at that. Does that set a default alias for the screen session?

CTRL+A-D actually. You can also do CTRL+A-C to create a new terminal while in screen and CTRL+A-N/P to switch to the next/previous terminal. Look through the manual for all the commands.

Yeah, I saw there where tons of shortcuts.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...