Bug 2081614 - When multiplexed ssh connection is added, loginctl no longer displays the TTY information
Summary: When multiplexed ssh connection is added, loginctl no longer displays the TTY...
Keywords:
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: systemd
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: systemd maint
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-05-04 07:58 UTC by Jan Pazdziora
Modified: 2023-08-14 11:27 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
My POC patch to list all TTYs. (6.53 KB, text/plain)
2022-06-28 11:55 UTC, Jan Pazdziora
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-120969 0 None None None 2022-05-04 08:08:57 UTC

Description Jan Pazdziora 2022-05-04 07:58:04 UTC
Description of problem:

The ssh has the ability to run multiple sessions via single network connection with ControlMaster and ControlPath options. Each of those sessions gets its own terminal. However, when the second ssh session is started through existing connection, it "connect" to the existing logind session, and loginctl no longer displays the terminal (TTY) information.

Version-Release number of selected component (if applicable):

systemd-250-6.el9_0

How reproducible:

Deterministic.

Steps to Reproduce:
1. In first terminal make a ssh connection from root to user test:
   root@localhost# ssh -tt -o 'ControlMaster auto' -o 'ControlPath /tmp/ssh-%r@%h:%p' -o 'StrictHostKeyChecking no' test@localhost sleep 600
2. In second terminal check that session got created for user test and that it lists the TTY:
   root@localhost# SESSION=$( loginctl -p Sessions --value show-user test )
   root@localhost# loginctl session-status $SESSION
   root@localhost# loginctl session-status $SESSION | grep TTY:
3. In third terminal start second session as user test using the existing ssh connection:
   root@localhost# ssh -tt -o 'ControlMaster auto' -o 'ControlPath /tmp/ssh-%r@%h:%p' -o 'StrictHostKeyChecking no' test@localhost sleep 600
2. In the secont terminal check that session knows about the TTYS:
   root@localhost# loginctl session-status $SESSION
   root@localhost# loginctl session-status $SESSION | grep TTY:

Actual results:

In step 2:

+++ loginctl -p Sessions --value show-user test
++ SESSION=4
++ loginctl session-status 4
4 - test (1000)
	   Since: Wed 2022-05-04 09:37:46 CEST; 12s ago
	  Leader: 4756 (sshd)
	     TTY: pts/0
	  Remote: ::1
	 Service: sshd; type tty; class user
	   State: active
	    Unit: session-4.scope
		  ├─4756 "sshd: test [priv]"
		  ├─4759 "sshd: test@pts/0"
		  └─4760 sleep 600

May 04 09:37:46 cc-vm1p.tpb.lab.eng.brq.redhat.com systemd[1]: Started Session 4 of User test.
++ loginctl session-status 4
++ grep TTY:
	     TTY: pts/0

In step 4:

+++ loginctl -p Sessions --value show-user test
++ SESSION=4
++ loginctl session-status 4
4 - test (1000)
	   Since: Wed 2022-05-04 09:37:46 CEST; 34s ago
	  Leader: 4756 (sshd)
	  Remote: ::1
	 Service: sshd; type tty; class user
	   State: active
	    Unit: session-4.scope
		  ├─4756 "sshd: test [priv]"
		  ├─4759 "sshd: test@pts/0,pts/1"
		  ├─4760 sleep 600
		  └─5114 sleep 600

May 04 09:37:46 cc-vm1p.tpb.lab.eng.brq.redhat.com systemd[1]: Started Session 4 of User test.
++ loginctl session-status 4
++ grep TTY:

Note that the TTY information is missing, even if both pts' are listed for the sshd process 4759.

Expected results:

In step 2 as above.

In step 4:

+++ loginctl -p Sessions --value show-user test
++ SESSION=4
++ loginctl session-status 4
4 - test (1000)
	   Since: Wed 2022-05-04 09:37:46 CEST; 34s ago
	  Leader: 4756 (sshd)
	  Remote: ::1
	 Service: sshd; type tty; class user
	   State: active
	    Unit: session-4.scope
		  ├─4756 "sshd: test [priv]"
		  ├─4759 "sshd: test@pts/0,pts/1"
		  ├─4760 sleep 600
		  └─5114 sleep 600

May 04 09:37:46 cc-vm1p.tpb.lab.eng.brq.redhat.com systemd[1]: Started Session 4 of User test.
++ loginctl session-status 4
++ grep TTY:
	     TTY: pts/0 pts/1

Or some other representation of the TTYs related to the logind session.

Additional info:

When the second ssh session (in that third terminal) is killed, loginctl still does not show that (now single) pts/0 TTY for the logind session.

Comment 2 Jan Pazdziora 2022-06-23 12:52:07 UTC
I have a proof of concept patch that I created to test a patch for bug 2100464 with ssh connections. I'd be happy to attach it if you feel that it might make the discussion about a fix easier.

Comment 3 Jan Pazdziora 2022-06-28 11:55:10 UTC
Created attachment 1893168 [details]
My POC patch to list all TTYs.


Note You need to log in before you can comment on or make changes to this bug.