I'm experiencing a strange behavior on some of our machines atm. At least, it seems strange to me and my colleagues and we didn't find any explanation for it :)
Next paragraph seems to be wrong. See edit 2 at end.
We're using bash and zsh here. So, when SSHing into some of the zsh-default-machines (plain
ssh login@host) which are configured to use zsh as default shell (with
chsh -s /usr/bin/zsh), the then-opened shell is an interactive but non-login shell, regardless if we're already logged in on the respective machine or not.
In my understanding, SSHing into a machine should be starting a new user session on that machine, thus requiring the shell to be a login shell, right? Shouldn't that be the case for zsh, too?
When changing the default shell to bash on the machines, logging into the machine uses a login-shell.
Is this the normal behavior for zsh? Could it be changed? Or is it some misconfiguration?
[edit 2] Ok, according to the ZSH documentation you could easily test if it is a login shell or not:
$ if [[ -o login ]]; then; print yes; else; print no; fi
However, due to zsh man entry / documentation, zsh should source
/etc/profile which in turn sources the scripts under
/etc/profile.d/*.sh. My question above originated in the fact, that the scripts are not sourced and thus most of our environment variables and system configuration stuff isn't properly initialized. However, as described above - when we're using bash as default shell,
/etc/profile and the scripts in the profile.d-folder are sourced.
[edit 3 - ANSWER]
Thx @StéphaneChazelas for the answer in the comments below!
zsh is only sourcing
/etc/profile when running in
ksh compatibility mode (see the respecitve man entry https://linux.die.net/man/1/zsh).
As logging in via SSH doesn't trigger that compatibility mode,
zsh doesn't necessarily source
/etc/profile on it's own but have to be triggered via
System: OS: Ubuntu 18.04 zsh-5.4.2 with omz and some plugins activated.