PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.security.ssh > "Leaving" a connection open / Sessions
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.security.ssh SSH secure remote login and tunneling tools.

"Leaving" a connection open / Sessions

Réponse
 
LinkBack Outils de la discussion
Vieux 14/09/2006, 03h22   #1 (permalink)
sgb1010@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut "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

  Réponse avec citation
Vieux 14/09/2006, 03h43   #2 (permalink)
Todd H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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/
  Réponse avec citation
Vieux 14/09/2006, 03h46   #3 (permalink)
Gustavo L. Fabro
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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

  Réponse avec citation
Vieux 14/09/2006, 03h48   #4 (permalink)
sgb1010@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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

  Réponse avec citation
Vieux 14/09/2006, 03h57   #5 (permalink)
Ignoramus7715
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: "Leaving" a connection open / Sessions

On 13 Sep 2006 21:43:13 -0500, Todd H. <comp@toddh.net> 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.
>


  Réponse avec citation
Vieux 14/09/2006, 04h36   #6 (permalink)
Todd H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: "Leaving" a connection open / Sessions

"Gustavo L. Fabro" <glfabro@gmail.com> 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/
  Réponse avec citation
Vieux 14/09/2006, 05h33   #7 (permalink)
Ignoramus7715
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: "Leaving" a connection open / Sessions

On 13 Sep 2006 22:36:01 -0500, Todd H. <comp@toddh.net> wrote:
> "Gustavo L. Fabro" <glfabro@gmail.com> 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

  Réponse avec citation
Vieux 15/09/2006, 03h12   #8 (permalink)
Todd H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: "Leaving" a connection open / Sessions

Ignoramus7715 <ignoramus7715@NOSPAM.7715.invalid> 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/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h06.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13666 seconds with 16 queries