VM default shell sh vs. bash in Ubuntu 22.04 and 24.04 VMs
Does anyone know if and why the default shell changed from bash to sh between the Ubuntu 22.04 and 24.04 VM images? And what the right way is to configure it to be bash for new human users, including those created by AadSshLoginForLinux?
In our older Linux VMs created using the Ubuntu 22.04 and Ubuntu 20.04 VM images from Canonical in the marketplace images for "Ubuntu Server 20.04 LTS" and "Ubuntu Server 22.04 LTS", the default shell that new users got was bash. In new VMs created with the "Ubuntu 24.04 LTS - all plans including Ubuntu Pro" images, they're getting plain /bin/sh, which makes for a lousy interactive shell and isn't compatible with most of our users' shell startup scripts, which use bashisms.
In the new 24.04 VMs, /etc/default/useradd has it set to /bin/sh, saying this:
# The SHELL variable specifies the default login shell on your
# system.
# Similar to DSHELL in adduser. However, we use "sh" here because
# useradd is a low level utility and should be as general
# as possible
SHELL=/bin/sh
In the old 22.04 VMs, it has /bin/bash. Though it still has the comment about using "sh".
# Similar to DSHELL in adduser. However, we use "sh" here because
# useradd is a low level utility and should be as general
# as possible
SHELL=/bin/bash
I don't recall ever changing that myself, and have built several VMs from these images. And non-Azure Ubuntu VMs that I build from the vanilla Ubuntu distro downloads have /bin/sh there. So I assume this is a customization in the Azure marketplace VM images?
Does anyone know why this customization went away in the Ubuntu 24.04 VM images and it's /bin/sh now?
This is a minor bummer because we use Entra AD login (AADSSHLoginForLinux) on these VMs, and chsh doesn't work with Entra AD backed users, as described in this Stack Overflow question.[1] And some users don't know about chsh anyway. So an admin has to change it for them, by editing /etc/aadpasswd
.
I've been changing our /etc/default/aaduseradd
to set the default shell to bash there. Seems to work. Is that the right place to do it? (Assuming the /etc/defult/useradd customization went away for a reason, and wasn't just forgotten when building the 24.04 VM images.)
# The SHELL variable.
SHELL=/bin/bash
Relatedly, does anyone know how to get chsh
or similar to work with Entra AD login? Or if it is expected to work with Entra AD login?
[1] https://serverfault.com/questions/1114802/setting-default-shell-on-azure-linux-vm-using-aad-login