- Package:
- openssh-server
- Source:
- openssh-server
- Description:
- secure shell (SSH) server, for secure access from remote machines
- Submitter:
- Chris Hofstaedtler
- Date:
- 2025-02-17 17:36:06 UTC
- Severity:
- normal
- Tags:
Recently I've become aware of ssh sessions no longer showing a value for "TTY"
in w(1) and loginctl list-sessions. I think this leads to issues like wall(1) /
shutdown / ... not delivering messages to the terminals of users logged in via
ssh.
Just to clarify, what I'm seeing:
17:10 ch@tiksta:~ % w
17:10:57 up 1:30, 3 users, load average: 0.08, 0.04, 0.07
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
ch - 15:48 1:30m 0.00s 0.10s /usr/lib/systemd/systemd --user
ch tty2 - 17:02 8:57 0.05s 0.05s -zsh
ch 192.168.67.1 17:10 1:30m 0.00s 0.04s sshd-session: ch [priv]
The last of these entries is my session logged in via ssh. The running shell says:
17:10 ch@tiksta:~ % echo $TTY
/dev/pts/0
I would have expected w(1) to show pts/0 in the TTY column, like it did on
bookworm. Local logins (using login) still show a TTY in w(1), for
example the second entry in above's output.
loginctl also has no info on the TTY:
17:13 ch@tiksta:~ % loginctl list-sessions
SESSION UID USER SEAT LEADER CLASS TTY IDLE SINCE
2 1000 ch - 796 manager - no -
6 1000 ch seat0 40849 user tty2 no -
7 1000 ch - 40920 user - no -
(The last line should show pts/0 here.)
I don't know if the observed behaviour is an effect of utmp going
away, or caused by other changes in sshd. Could you please check
what's going on there?
Thanks,
Chris
Control: forwarded -1 https://github.com/openssh/openssh-portable/pull/403 [...] While reading up on this I ran across https://github.com/openssh/openssh-portable/pull/403, whose description sounds like the same thing.
* Colin Watson <cjwatson@debian.org> [241117 00:32]: Possible, but that will not fix reporting the tty to logind. I'm wondering if something in sshd changed so that the tty is not available/visible to PAM anymore? If PAM knows about the tty, pam_systemd.so and pam_wtmpdb.so should hopefully just record it. Chris
I've now read up on the PR, and I think it will not solve the problem. Having the session recorded in wtmpdb is nice, but we already have pam_wtmpdb for that. who(1) talks to logind for getting currently logged in sessions. wtmpdb is irrelevant for this. We need that part to work (again?). (I also think linking libwtmpdb.so into sshd is not a good idea.) Chris
Fair enough. I suspect this may be related to PAM_TTY_KLUDGE, then (https://anongit.mindrot.org/openssh.git/tree/auth-pam.c#n760). Maybe as well as setting a kludged PAM_TTY for pam_auth, sshd needs to set a proper one for pam_session? It would be sshd-session, not sshd, so much less problematic than pre-auth linkage.
Control: forwarded -1 https://github.com/openssh/openssh-portable/pull/433 I think so? Is it easy for you to build an sshd that does this? The last time I looked at the openssh code trying to understand where this might need to be patched in I got lost very quickly. I just found another upstream PR, which would directly talk to logind. Upstream doesn't seem to like it: https://github.com/openssh/openssh-portable/pull/433 Chris