"Leaving" a connection open / Sessions - SSH

This is a discussion on "Leaving" a connection open / Sessions - SSH ; Greetings! Is there a way to leave a connection open in SSH, something as a 'session' which can be restored later? My scenario is the following: I connect to a remote machine (which has sshd) via SSH, run octave, run ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: "Leaving" a connection open / Sessions

  1. "Leaving" a connection open / Sessions

    Greetings!

    Is there a way to leave a connection open in SSH, something as a
    'session' which can be restored later?

    My scenario is the following: I connect to a remote machine (which has
    sshd) via SSH, run octave, run a long script (which will probably take
    about a month to complete), hit Ctrl+Z, type BG. So far so good, my
    application goes to background.

    What I would like to do next would be to log out of this ssh connection
    and, when I return (with the same user), be able to fg %1 and return to
    the running program. Right now when I try to do this I get a message
    saying I can't, because there are jobs running on the background.

    Is there a way to accomplish this? Some configuration in sshd perhaps?
    I wouldn't like to have to leave two machines turned on whereas one
    would suffice.

    Thanking you for your attention,

    Soleth


  2. Re: "Leaving" a connection open / Sessions

    sgb1010@hotmail.com writes:

    > Greetings!
    >
    > Is there a way to leave a connection open in SSH, something as a
    > 'session' which can be restored later?


    I think you're about to fall in love with Gnu screen.

    > My scenario is the following: I connect to a remote machine (which has
    > sshd) via SSH, run octave, run a long script (which will probably take
    > about a month to complete), hit Ctrl+Z, type BG. So far so good, my
    > application goes to background.
    >
    > What I would like to do next would be to log out of this ssh connection
    > and, when I return (with the same user), be able to fg %1 and return to
    > the running program. Right now when I try to do this I get a message
    > saying I can't, because there are jobs running on the background.
    >
    > Is there a way to accomplish this? Some configuration in sshd perhaps?
    > I wouldn't like to have to leave two machines turned on whereas one
    > would suffice.


    ssh blah@remotehost
    remotehost$ screen

    [hit enter after swcreen's introductory comments]

    remotehostinscreen$ . .bash_profile (if ya need to, screen doesn't always
    fork as a login shell, so you may need to source this)

    remotehostinscreen$ myfunprocess&
    remotehostinscreen$ [Ctrl-a d]
    [detached]

    remotehost$ exit



    Days later, from some completely different machine, reconnect to
    remotehost via any method.

    remotehost$ screen -r
    remotehostinscreen$

    you'll be right back where you were.

    Think of screen as VNC for tty's. -r reconnects you. Ctrl-a
    followed by d disconnects you. Or hell ust kill the terminal.
    Screen is still there.


    Enjoy! Screen rocks.

    --
    Todd H.
    http://www.toddh.net/

  3. Re: "Leaving" a connection open / Sessions



    > Enjoy! Screen rocks.


    Beautiful!!! Exactly what I wanted!!!!!!

    Thank you very much! Works as a charm! You guessed right, I'm indeed in
    love with this new tool! ;-)

    Soleth


  4. Re: "Leaving" a connection open / Sessions


    > Enjoy! Screen rocks.


    Beautiful!!! Exactly what I wanted!!!!!!

    Thank you very much! Works as a charm! You guessed right, I'm indeed in
    love with this new tool! ;-)

    Soleth


  5. Re: "Leaving" a connection open / Sessions

    On 13 Sep 2006 21:43:13 -0500, Todd H. wrote:
    > sgb1010@hotmail.com writes:
    >
    >> Greetings!
    >>
    >> Is there a way to leave a connection open in SSH, something as a
    >> 'session' which can be restored later?

    >
    > I think you're about to fall in love with Gnu screen.


    I second the recomendation, I have used it for years and love it.

    i

    >> My scenario is the following: I connect to a remote machine (which has
    >> sshd) via SSH, run octave, run a long script (which will probably take
    >> about a month to complete), hit Ctrl+Z, type BG. So far so good, my
    >> application goes to background.
    >>
    >> What I would like to do next would be to log out of this ssh connection
    >> and, when I return (with the same user), be able to fg %1 and return to
    >> the running program. Right now when I try to do this I get a message
    >> saying I can't, because there are jobs running on the background.
    >>
    >> Is there a way to accomplish this? Some configuration in sshd perhaps?
    >> I wouldn't like to have to leave two machines turned on whereas one
    >> would suffice.

    >
    > ssh blah@remotehost
    > remotehost$ screen
    >
    > [hit enter after swcreen's introductory comments]
    >
    > remotehostinscreen$ . .bash_profile (if ya need to, screen doesn't always
    > fork as a login shell, so you may need to source this)
    >
    > remotehostinscreen$ myfunprocess&
    > remotehostinscreen$ [Ctrl-a d]
    > [detached]
    >
    > remotehost$ exit
    >
    >
    >
    > Days later, from some completely different machine, reconnect to
    > remotehost via any method.
    >
    > remotehost$ screen -r
    > remotehostinscreen$
    >
    > you'll be right back where you were.
    >
    > Think of screen as VNC for tty's. -r reconnects you. Ctrl-a
    > followed by d disconnects you. Or hell ust kill the terminal.
    > Screen is still there.
    >
    >
    > Enjoy! Screen rocks.
    >



  6. Re: "Leaving" a connection open / Sessions

    "Gustavo L. Fabro" writes:

    > > Enjoy! Screen rocks.

    >
    > Beautiful!!! Exactly what I wanted!!!!!!
    >
    > Thank you very much! Works as a charm! You guessed right, I'm indeed in
    > love with this new tool! ;-)


    One more switch to know...

    If when you do screen -r to reattach it complains that there aren't
    any unattached screens (which will happen if you get disconnected
    (e.g. network blip) and then try reconnect relatively quickly), in
    that case:

    remotehost$ screen -r -d

    will force the detaching of your prior screen session and get you back
    where you wanna be.

    If you're an emacs user and want to remap the control-a to something
    else, drop something like this in .screenrc

    escape ^Tt

    (I map mine to Ctrl-t since Ctrl-a is beginning of line in emacs and
    I use it all the time. )


    And now, I get to introduce you to new virtual screens. :-)

    From inside of screen. Try Ctrl-a c (c for create)

    This creates a new shell inside of screen.

    To toggle back to the other one, do Ctrl-a n (n for next). Repeat
    as desired.

    Have fun! I <3 screen.


    --
    Todd H.
    http://www.toddh.net/

  7. Re: "Leaving" a connection open / Sessions

    On 13 Sep 2006 22:36:01 -0500, Todd H. wrote:
    > "Gustavo L. Fabro" writes:
    >
    >> > Enjoy! Screen rocks.

    >>
    >> Beautiful!!! Exactly what I wanted!!!!!!
    >>
    >> Thank you very much! Works as a charm! You guessed right, I'm indeed in
    >> love with this new tool! ;-)

    >
    > One more switch to know...
    >
    > If when you do screen -r to reattach it complains that there aren't
    > any unattached screens (which will happen if you get disconnected
    > (e.g. network blip) and then try reconnect relatively quickly), in
    > that case:
    >
    > remotehost$ screen -r -d
    >
    > will force the detaching of your prior screen session and get you back
    > where you wanna be.


    even better is to type screen -d -R, that would reattach the screen if
    it exists, or create a new one.

    > If you're an emacs user and want to remap the control-a to something
    > else, drop something like this in .screenrc
    >
    > escape ^Tt
    >
    > (I map mine to Ctrl-t since Ctrl-a is beginning of line in emacs and
    > I use it all the time. )


    Just get used to it.

    i


  8. Re: "Leaving" a connection open / Sessions

    Ignoramus7715 writes:

    > even better is to type screen -d -R, that would reattach the screen if
    > it exists, or create a new one.


    Ooh... I like it!

    > > If you're an emacs user and want to remap the control-a to something
    > > else, drop something like this in .screenrc
    > >
    > > escape ^Tt
    > >
    > > (I map mine to Ctrl-t since Ctrl-a is beginning of line in emacs and
    > > I use it all the time. )

    >
    > Just get used to it.


    Too many years... I couldn't! :-)


    --
    Todd H.
    http://www.toddh.net/

+ Reply to Thread