I see an unexplained difference in behavior with ssh on Linux and FreeBSD, and it is the FreeBSD behavior that I would expect from the plain language of the manpages. So, something extra happens on Linux, but I don't know what it is.
I use bash as my normal login shell on all systems, both Linux and BSD. With a complex multi-stage setup involving the bash startup files, I set up my environment variables for all incarnations of bash that are either "login" or "interactive" shell, in the technical sense spelled out in the beginning of the bash manpage.
Now, the difference: when I ssh into a FreeBSD server with a command, for example ssh freebsd-host printenv
, those variables are not set. Which, after some thinking, is what I should expect, since the shell in that case is neither login nor interactive. But, when I ssh in the same way into a Linux host, the variables are in fact set -- a sure sign that either the .bash_profile
or the .bashrc
file has been grokked somehow or other, despite the non-status of the shell.
My question is of course, why and how can Linux behave this way? What it is that makes the bash startup be run under these circumstances? All the sshd configuration is exactly the same and close to the upstream defaults, including PermitUserEnvironment=no
. All the Linuxes are variants on Debian, if it matters.
A bonus anecdote: I stumbled into this when I read some manpages with ssh -t host man man
and I noticed nothing unusual on a remote Linux, but on a remote FreeBSD the manpage came out ungodly narrow -- because my ubiquitous setting of MANWIDTH=100
wasn't there.