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.
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.
Created attachment 1893168 [details] My POC patch to list all TTYs.