Skip to content

set TERM for +ssh without clobbering the user's SetEnv - #14854

Merged
mitchellh merged 1 commit into
mainfrom
ssh-env
Oct 26, 2026
Merged

mitchellh merged 1 commit into
mainfrom
ssh-env

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

+ssh passed -o SetEnv=TERM=... to ssh. ssh only uses the first SetEnv it finds, so the one on the command line replaced every SetEnv entry in the user's ssh config. This brings back the bug that #11518 fixed in the old shell integration wrapper, now in +ssh (#12582).

TERM was also only set with --forward-env, so --forward-env=false (what ssh-terminfo-only users get) left the inherited TERM=xterm-ghostty in place even when the terminfo install failed.

ssh sends the SetEnv entries in the user's ssh config again, and a failed terminfo install falls back to xterm-256color like it did in 1.3.1, no matter which ssh-* features are enabled.

TERM is now set in the environment of the ssh process instead of with SetEnv, the same way the 1.3.1 wrapper did. ssh sends TERM on its own when it opens a remote terminal, so the server doesn't need AcceptEnv TERM. This happens whenever --forward-env or --terminfo is enabled. With both disabled, ssh runs with the user's environment unchanged. The +ssh help is updated to explain how TERM is chosen.

Docs: https://man.openbsd.org/ssh_config#SetEnv

`+ssh` passed `-o SetEnv=TERM=...` to ssh. ssh only uses the first
SetEnv it finds, so the one on the command line replaced every SetEnv
entry in the user's ssh config. This brings back the bug that #11518
fixed in the old shell integration wrapper, now in `+ssh` (#12582).

`TERM` was also only set with `--forward-env`, so `--forward-env=false`
(what `ssh-terminfo`-only users get) left the inherited
`TERM=xterm-ghostty` in place even when the terminfo install failed.

ssh sends the SetEnv entries in the user's ssh config again, and
a failed terminfo install falls back to `xterm-256color` like it
did in 1.3.1, no matter which `ssh-*` features are enabled.

`TERM` is now set in the environment of the ssh process instead of
with SetEnv, the same way the 1.3.1 wrapper did. ssh sends `TERM` on
its own when it opens a remote terminal, so the server doesn't need
`AcceptEnv TERM`. This happens whenever `--forward-env` or
`--terminfo` is enabled. With both disabled, ssh runs with the user's
environment unchanged. The `+ssh` help is updated to explain how
`TERM` is chosen.

Docs: https://man.openbsd.org/ssh_config#SetEnv
@mitchellh mitchellh added this to the 1.4.0 milestone Oct 26, 2026
@mitchellh
mitchellh requested a review from jparise October 26, 2026 15:18
@mitchellh
mitchellh merged commit 37b7101 into main Oct 26, 2026
119 checks passed
@mitchellh
mitchellh deleted the ssh-env branch October 26, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants