[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Logging off an X session closes all ssh -X connections started previously from outside X

On 2023-05-09 20:07:26 +0200, zithro wrote:
> On 09 May 2023 18:06, Vincent Lefevre wrote:
> > On 2023-05-05 15:04:27 +0200, zithro wrote:
> > > --------------------------------------------------------------------
> > > journalctl after GUI LOGOFF
> > > --------------------------------------------------------------------
> > [...]
> > > May 05 14:09:14 debzit sshd[14246]: Received disconnect from IP.IP.IP.IP
> > > port 38524:11: disconnected by user
> >                   ^^^^^^^^^^^^^^^^^^^^
> > 
> > "disconnected by user": Doesn't this mean that it is the client that
> > did the disconnection (for whatever reason)?
> I dunno, but it happens when the server-side logoff is requested from X ...
> Can't see the relation : how can a server X logoff send a request to the ssh
> command on the client ?!?!

I agree that this is strange.

> However I just tried, I killed an ssh session from the server, didn't get
> the "disconnect" message in logs.
> Although I don't know if killing (via SIGTERM) is equivalent to what
> whatever the system uses to close the ssh sessions when my problem is
> happening.

You can also try with SIGHUP (but I would be surprised if the result
were different).

> > This is the message I observe when I disconnect the ssh session from
> > the client (with "~.") instead of terminating the program (e.g. shell)
> > on the server side.
> Same here for normal exits, or I think so ?
> I use Ctrl-D to close ssh sessions, "~." does not work, I get "bash: command
> not found".

As Greg said, you need to type [Enter] first (otherwise the escape
character would be triggered too often).

FYI, in the ssh(1) man page:

  -e escape_char
      Sets the escape character for sessions with a pty (default: ‘~’).
      The escape character is only recognized at the beginning of a
      line.  The escape character followed by a dot (‘.’) closes the
      connection; followed by control-Z suspends the connection; and
      followed by itself sends the escape character once.  Setting the
      character to “none” disables any escapes and makes the session
      fully transparent.

Note that Ctrl-D terminates the remote shell, which has the effect
to terminate the ssh session *from the server* (the remote side).
On the contrary, "~." at the beginning of a line terminates the
ssh session on the client side (the escape character is interpreted
by the ssh client, and the sshd server does not see it).

Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Reply to: