public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Keep alive within SSH session
@ 2016-07-17 14:02 Mick
  2016-07-17 14:20 ` Ralf
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Mick @ 2016-07-17 14:02 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 882 bytes --]

I am not sure of the correct approach to achieve a prolonged remote debugging 
session through SSH and avoid the SSH session timing out.

This is what I try to achieve:

I login into a router with SSH from my PC.  Then I can run certain commands to 
start and monitor a debugging session in the router.  However, if I leave 
alone the SSH session, it will soon time out.  The debugging only runs while 
the session is live.  Exiting the SSH session causes all debug output to be 
lost.

If I continue to run (router) commands on the terminal, while the debugging is 
running, the SSH time out is postponed.

What do you suggest I try on an SSH terminal from my PC to keep running 
recurring commands after I have connected to the router?  I will need to keep 
a debugging session going for some hours, in order to collect the data I'm 
after.

-- 
Regards,
Mick

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
@ 2016-07-17 14:20 ` Ralf
  2016-07-17 16:35   ` Mick
  2016-07-17 18:22 ` R0b0t1
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Ralf @ 2016-07-17 14:20 UTC (permalink / raw
  To: gentoo-user

On 07/17/2016 04:02 PM, Mick wrote:
> I am not sure of the correct approach to achieve a prolonged remote debugging 
> session through SSH and avoid the SSH session timing out.
>
> This is what I try to achieve:
>
> I login into a router with SSH from my PC.  Then I can run certain commands to 
> start and monitor a debugging session in the router.  However, if I leave 
> alone the SSH session, it will soon time out.  The debugging only runs while 
> the session is live.  Exiting the SSH session causes all debug output to be 
> lost.
Take a look at screen or tmux. man screen, man tmux.
>
> If I continue to run (router) commands on the terminal, while the debugging is 
> running, the SSH time out is postponed.
you may also want to tweak some timeout options in your sshd_config
>
> What do you suggest I try on an SSH terminal from my PC to keep running 
> recurring commands after I have connected to the router?  I will need to keep 
> a debugging session going for some hours, in order to collect the data I'm 
> after.
>



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:20 ` Ralf
@ 2016-07-17 16:35   ` Mick
  2016-07-17 17:14     ` David M. Fellows
  2016-07-17 22:30     ` Todd Goodman
  0 siblings, 2 replies; 14+ messages in thread
From: Mick @ 2016-07-17 16:35 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1409 bytes --]

On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
> On 07/17/2016 04:02 PM, Mick wrote:
> > I am not sure of the correct approach to achieve a prolonged remote
> > debugging session through SSH and avoid the SSH session timing out.
> > 
> > This is what I try to achieve:
> > 
> > I login into a router with SSH from my PC.  Then I can run certain
> > commands to start and monitor a debugging session in the router. 
> > However, if I leave alone the SSH session, it will soon time out.  The
> > debugging only runs while the session is live.  Exiting the SSH session
> > causes all debug output to be lost.
> 
> Take a look at screen or tmux. man screen, man tmux.

Thank you Ralph, but detaching the *local* terminal process of SSH does not in 
any way stop the login session on the router from timing out.


> > If I continue to run (router) commands on the terminal, while the
> > debugging is running, the SSH time out is postponed.
> 
> you may also want to tweak some timeout options in your sshd_config

The router login times out unless some command is fed into the login session a 
the time.  So, I'll need to be able to run commands every so often on the 
router shell from within my SSH session (without sitting in front of my PC 
terminal of course).  The commands 'watch', or 'at' might do it, but I am not 
sure if some script is necessary for this.

-- 
Regards,
Mick

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 16:35   ` Mick
@ 2016-07-17 17:14     ` David M. Fellows
  2016-07-17 17:47       ` Mick
  2016-07-17 22:30     ` Todd Goodman
  1 sibling, 1 reply; 14+ messages in thread
From: David M. Fellows @ 2016-07-17 17:14 UTC (permalink / raw
  To: gentoo-user, Mick

On Sun, 17 Jul 2016 17:35:55 +0100 
Mick wrote -
> On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
> > On 07/17/2016 04:02 PM, Mick wrote:
> > > I am not sure of the correct approach to achieve a prolonged remote=
> 
> > > debugging session through SSH and avoid the SSH session timing out.=
> 

What you need is expect or Expect or pexpect depending on your base
scripting language preference - tcl, perl, or python.

Dave F


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 17:14     ` David M. Fellows
@ 2016-07-17 17:47       ` Mick
  2016-07-17 18:03         ` lukash
  0 siblings, 1 reply; 14+ messages in thread
From: Mick @ 2016-07-17 17:47 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

On Sunday 17 Jul 2016 14:14:42 you wrote:
> On Sun, 17 Jul 2016 17:35:55 +0100
> Mick wrote -
> 
> > On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
> > > On 07/17/2016 04:02 PM, Mick wrote:
> > > > I am not sure of the correct approach to achieve a prolonged remote=
> > > > 
> > > > debugging session through SSH and avoid the SSH session timing out.=
> 
> What you need is expect or Expect or pexpect depending on your base
> scripting language preference - tcl, perl, or python.
> 
> Dave F

Thank you Dave!  I'm emerging dev-tcltk/expect as I type this.  Hopefully the 
learning curve won't be too steep.  ;-)

-- 
Regards,
Mick

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 17:47       ` Mick
@ 2016-07-17 18:03         ` lukash
  2016-07-22  5:33           ` Daniel Campbell
  0 siblings, 1 reply; 14+ messages in thread
From: lukash @ 2016-07-17 18:03 UTC (permalink / raw
  To: gentoo-user

On Sun, 2016-07-17 at 18:47 +0100, Mick wrote:
> On Sunday 17 Jul 2016 14:14:42 you wrote:
> > On Sun, 17 Jul 2016 17:35:55 +0100
> > Mick wrote -
> > 
> > > On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
> > > > On 07/17/2016 04:02 PM, Mick wrote:
> > > > > I am not sure of the correct approach to achieve a prolonged
> > > > > remote=
> > > > > 
> > > > > debugging session through SSH and avoid the SSH session
> > > > > timing out.=
> > 
> > What you need is expect or Expect or pexpect depending on your base
> > scripting language preference - tcl, perl, or python.
> > 
> > Dave F
> 
> Thank you Dave!  I'm emerging dev-tcltk/expect as I type
> this.  Hopefully the 
> learning curve won't be too steep.  ;-)

You may also wanna try the ServerAliveInterval option in your client's
ssh config. It sends some keepalive data to the server every X seconds,
sounds like what you need.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
  2016-07-17 14:20 ` Ralf
@ 2016-07-17 18:22 ` R0b0t1
  2016-07-17 22:31 ` Adam Carter
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: R0b0t1 @ 2016-07-17 18:22 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

The proper solution is to use TCP keep alive to prevent tunnel over tunnel
issues from arising.

[-- Attachment #2: Type: text/html, Size: 113 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 16:35   ` Mick
  2016-07-17 17:14     ` David M. Fellows
@ 2016-07-17 22:30     ` Todd Goodman
  1 sibling, 0 replies; 14+ messages in thread
From: Todd Goodman @ 2016-07-17 22:30 UTC (permalink / raw
  To: gentoo-user

* Mick <michaelkintzios@gmail.com> [160717 12:36]:
> On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
> > On 07/17/2016 04:02 PM, Mick wrote:
> > > I am not sure of the correct approach to achieve a prolonged remote
> > > debugging session through SSH and avoid the SSH session timing out.
> > > 
> > > This is what I try to achieve:
> > > 
> > > I login into a router with SSH from my PC.  Then I can run certain
> > > commands to start and monitor a debugging session in the router. 
> > > However, if I leave alone the SSH session, it will soon time out.  The
> > > debugging only runs while the session is live.  Exiting the SSH session
> > > causes all debug output to be lost.
> > 
> > Take a look at screen or tmux. man screen, man tmux.
> 
> Thank you Ralph, but detaching the *local* terminal process of SSH does not in 
> any way stop the login session on the router from timing out.
> 
> 
> > > If I continue to run (router) commands on the terminal, while the
> > > debugging is running, the SSH time out is postponed.
> > 
> > you may also want to tweak some timeout options in your sshd_config
> 
> The router login times out unless some command is fed into the login session a 
> the time.  So, I'll need to be able to run commands every so often on the 
> router shell from within my SSH session (without sitting in front of my PC 
> terminal of course).  The commands 'watch', or 'at' might do it, but I am not 
> sure if some script is necessary for this.
> 
> -- 
> Regards,
> Mick


if you just want something to keep the connection open how about just a
simple shell command in a whole loop?

e.g., while true; do clear; ps aux | grep whatever; sleep 5; done


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
  2016-07-17 14:20 ` Ralf
  2016-07-17 18:22 ` R0b0t1
@ 2016-07-17 22:31 ` Adam Carter
  2016-07-18  9:02 ` Christian Rößner
  2016-07-19 15:55 ` Stefan G. Weichinger
  4 siblings, 0 replies; 14+ messages in thread
From: Adam Carter @ 2016-07-17 22:31 UTC (permalink / raw
  To: gentoo-user@lists.gentoo.org

[-- Attachment #1: Type: text/plain, Size: 642 bytes --]

On Mon, Jul 18, 2016 at 12:02 AM, Mick <michaelkintzios@gmail.com> wrote:

> I am not sure of the correct approach to achieve a prolonged remote
> debugging
> session through SSH and avoid the SSH session timing out.
>
> This is what I try to achieve:
>
> I login into a router with SSH from my PC.  Then I can run certain
> commands to
> start and monitor a debugging session in the router.  However, if I leave
> alone the SSH session, it will soon time out.
>

Have you checked the router config for a session timeout? Eg on a Cisco you
may have something like;

ssh timeout 30

Often setting this to 0 will disable the timeout, but RTFM.

[-- Attachment #2: Type: text/html, Size: 1032 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
                   ` (2 preceding siblings ...)
  2016-07-17 22:31 ` Adam Carter
@ 2016-07-18  9:02 ` Christian Rößner
  2016-07-19 15:55 ` Stefan G. Weichinger
  4 siblings, 0 replies; 14+ messages in thread
From: Christian Rößner @ 2016-07-18  9:02 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]


> Am 17.07.2016 um 16:02 schrieb Mick <michaelkintzios@gmail.com>:
> 
> I am not sure of the correct approach to achieve a prolonged remote debugging
> session through SSH and avoid the SSH session timing out.
> 
> This is what I try to achieve:
> 
> I login into a router with SSH from my PC.  Then I can run certain commands to
> start and monitor a debugging session in the router.  However, if I leave
> alone the SSH session, it will soon time out.  The debugging only runs while
> the session is live.  Exiting the SSH session causes all debug output to be
> lost.
> 
> If I continue to run (router) commands on the terminal, while the debugging is
> running, the SSH time out is postponed.
> 
> What do you suggest I try on an SSH terminal from my PC to keep running
> recurring commands after I have connected to the router?  I will need to keep
> a debugging session going for some hours, in order to collect the data I'm
> after.

I do this with a combination of "mosh" and "tmux". That works perfectly.

It even can catch disconnected DSL or Wifi.

Christian
--
Erlenwiese 14, 36304 Alsfeld
T: +49 6631 78823400, F: +49 6631 78823409, M: +49 171 9905345
USt-IdNr.: DE225643613, https://www.roessner-network-solutions.com


[-- Attachment #2: Message signed with OpenPGP using GPGMail --]
[-- Type: application/pgp-signature, Size: 841 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
                   ` (3 preceding siblings ...)
  2016-07-18  9:02 ` Christian Rößner
@ 2016-07-19 15:55 ` Stefan G. Weichinger
  2016-07-19 22:44   ` [gentoo-user] " Ian Zimmerman
  4 siblings, 1 reply; 14+ messages in thread
From: Stefan G. Weichinger @ 2016-07-19 15:55 UTC (permalink / raw
  To: gentoo-user

Am 2016-07-17 um 16:02 schrieb Mick:

> If I continue to run (router) commands on the terminal, while the debugging is
> running, the SSH time out is postponed.
>
> What do you suggest I try on an SSH terminal from my PC to keep running
> recurring commands after I have connected to the router?  I will need to keep
> a debugging session going for some hours, in order to collect the data I'm
> after.

one more suggestion:

autossh



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [gentoo-user] Re: Keep alive within SSH session
  2016-07-19 15:55 ` Stefan G. Weichinger
@ 2016-07-19 22:44   ` Ian Zimmerman
  2016-07-19 22:51     ` Stefan G. Weichinger
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Zimmerman @ 2016-07-19 22:44 UTC (permalink / raw
  To: gentoo-user

On 2016-07-19 17:55 +0200, Stefan G. Weichinger wrote:

> one more suggestion:
> 
> autossh

When I need a long-running ssh connection in the background (usually for
the -D or -L functionality), I do it with the supervisor daemon.

I admit I don't know if this would be workable for an interactive
session with a terminal.

-- 
Please *no* private Cc: on mailing lists and newsgroups
Why does the arrow on Hillary signs point to the right?


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Re: Keep alive within SSH session
  2016-07-19 22:44   ` [gentoo-user] " Ian Zimmerman
@ 2016-07-19 22:51     ` Stefan G. Weichinger
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan G. Weichinger @ 2016-07-19 22:51 UTC (permalink / raw
  To: gentoo-user

On 07/20/2016 12:44 AM, Ian Zimmerman wrote:
> On 2016-07-19 17:55 +0200, Stefan G. Weichinger wrote:
> 
>> one more suggestion:
>> 
>> autossh
> 
> When I need a long-running ssh connection in the background (usually
> for the -D or -L functionality), I do it with the supervisor daemon.
> 
> I admit I don't know if this would be workable for an interactive 
> session with a terminal.

I dunno exactly if autossh fits the OP's needs, I just use autossh
within systemd service files to keep up forwarded ssh tunnels to remote
systems successfully (current project in progress ... embedded systems
that should "call home" in a a way).

Most of the subscribers here know me as pro-systemd-gentoo-user ;-)



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [gentoo-user] Keep alive within SSH session
  2016-07-17 18:03         ` lukash
@ 2016-07-22  5:33           ` Daniel Campbell
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Campbell @ 2016-07-22  5:33 UTC (permalink / raw
  To: gentoo-user


[-- Attachment #1.1: Type: text/plain, Size: 1323 bytes --]

On 07/17/2016 11:03 AM, lukash wrote:
> On Sun, 2016-07-17 at 18:47 +0100, Mick wrote:
>> On Sunday 17 Jul 2016 14:14:42 you wrote:
>>> On Sun, 17 Jul 2016 17:35:55 +0100
>>> Mick wrote -
>>>
>>>> On Sunday 17 Jul 2016 16:20:30 Ralf wrote:
>>>>> On 07/17/2016 04:02 PM, Mick wrote:
>>>>>> I am not sure of the correct approach to achieve a prolonged
>>>>>> remote=
>>>>>>
>>>>>> debugging session through SSH and avoid the SSH session
>>>>>> timing out.=
>>>
>>> What you need is expect or Expect or pexpect depending on your base
>>> scripting language preference - tcl, perl, or python.
>>>
>>> Dave F
>>
>> Thank you Dave!  I'm emerging dev-tcltk/expect as I type
>> this.  Hopefully the 
>> learning curve won't be too steep.  ;-)
> 
> You may also wanna try the ServerAliveInterval option in your client's
> ssh config. It sends some keepalive data to the server every X seconds,
> sounds like what you need.
> 
Please let me know if you have any issues. I'm not an expert in Tcl (or
expect), but I help maintain the package and it's recently had bugs that
I attempted to fix, so let me know how it works out if you decide to go
that way.
-- 
Daniel Campbell - Gentoo Developer
OpenPGP Key: 0x1EA055D6 @ hkp://keys.gnupg.net
fpr: AE03 9064 AE00 053C 270C  1DE4 6F7A 9091 1EA0 55D6


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2016-07-22  5:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-17 14:02 [gentoo-user] Keep alive within SSH session Mick
2016-07-17 14:20 ` Ralf
2016-07-17 16:35   ` Mick
2016-07-17 17:14     ` David M. Fellows
2016-07-17 17:47       ` Mick
2016-07-17 18:03         ` lukash
2016-07-22  5:33           ` Daniel Campbell
2016-07-17 22:30     ` Todd Goodman
2016-07-17 18:22 ` R0b0t1
2016-07-17 22:31 ` Adam Carter
2016-07-18  9:02 ` Christian Rößner
2016-07-19 15:55 ` Stefan G. Weichinger
2016-07-19 22:44   ` [gentoo-user] " Ian Zimmerman
2016-07-19 22:51     ` Stefan G. Weichinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox