Uniquely Identifying the Local TTY of an SSH Connection

Damien Miller djm at mindrot.org
Tue Mar 7 10:02:32 AEDT 2023

On Fri, 3 Mar 2023, Ethan Pailes wrote:

> this sorta works, but there seems to be a strange interaction between
> the Control{Path,Master,Persist} options and SetEnv. If I try to
> immediately ssh to my remote host from two different terminals using
> `ssh main` then `ssh edit`, LC__LOCAL_TTY_NAME will get set to `main`
> in both, presumably because of some sticky state on the shared
> connection. Oddly, if I first do `ssh remote` in a separate terminal
> to use the SendEnv mechanism, then do `ssh main` and `ssh edit` in
> terminals two and three, this approach works as I was hoping and
> terminal two has LC__LOCAL_TTY_NAME set to `main` while terminal three
> has it set to `edit`. This feels like a bug in ssh to me, but maybe it
> is actually working as intended and I'm just holding it wrong.

hmm, that's not supposed to happen - the environment variables are
supposed to be sent separately for multiplexed sessions. We do have
a regression test for this (regress/multiplex.sh) so I have some
confidence that ssh should be doing the right thing here.


More information about the openssh-unix-dev mailing list