Score:0

Setting default shell on Azure Linux VM using AAD login?

cn flag

I am using the new Azure Active Directory ("AAD") Login mechanism to log in to Azure Ubuntu Linux VMs in my Azure environment, and I'd like to change the default shell for my user. The thing you'd normally do with chsh -s. chsh is not working for me, and I'm wondering what I'm supposed to do instead in this case. Does anybody know how to change the default shell for an AAD-authentication account on a Linux VM

I, and some of the other users at my work, would like to change their default shell to be zsh instead of bash, because we like zsh better for interactive use.

Here's what I see when I try to use chsh -s (redacted).

[email protected]@my-linux-box:~/repos$ whoami
[email protected]
[email protected]@my-linux-box:~/repos$ which zsh
/usr/bin/zsh
[email protected]@my-linux-box:~/repos$ grep zsh /etc/shells
/bin/zsh
/usr/bin/zsh
[email protected]@my-linux-box:~/repos$ chsh -s /usr/bin/zsh
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code *****AXTVTGR5F***** to authenticate.
When you sign in, verify the name of the app on the sign-in screen is "Azure Linux VM Sign-in" and the IP address of the VM is correct.
chsh: user '[email protected]' does not exist in /etc/passwd
[email protected]@my-linux-box:~/repos$ grep janke /etc/passwd
[email protected]@my-linux-box:~/repos$ 
[email protected]@lx-dev-01:~/repos$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

This is a Linux VM on Azure created from either the "Ubuntu Server 20.04 LTS" image and then upgraded with do-release-upgrade, or created from the "Ubuntu Server 22.04 LTS" image; I can't remember which.

If I were using OpenLDAP, there's a place in the LDAP directory to set a default shell on a per-user basis. But I don't see anything like that in Azure Active Directory.

I am using the "new" Azure AD Authentication for Linux mechanism described here - https://learn.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-linux - and not the old, deprecated one described here - https://learn.microsoft.com/en-us/previous-versions/azure/virtual-machines/linux/login-using-aad. The "device login" dialog shown above is in response to a chsh on the remote Linux VM, not part of an interactive-keyboard login process used to SSH in to that box in the first place.

I do not want to do the sloppy hack where you just throw an exec zsh call at the bottom of your ~/.bashrc file. If you do that, then it's hard to run an interactive bash, and we have reasons to do that for testing and code sharing and whatnot, even if we prefer to use zsh for most interactive shell scenarios.

Score:1
my flag

You need tools that target /etc/aadpasswd instead of /etc/passwd - when adding the AAD login extension you will get aaduseradd installed, through which can set your shell with sudo aaduseradd $USER -s <new shell> if you have root access.

There is, sadly, no equivalent to chsh installed, so you need someone with root access to change your shell.

Andrew Janke avatar
cn flag
Thanks Chloride! I got confirmation from Microsoft support staff that this is the case. You need `aadusermod` instead of `usermod` or `chsh`, and as of now (2023-03-29), `aadusermod` does not exist, so `sudo vi /etc/aadpasswd` it is for now. (`aaduseradd` can change a user's shell, but it also clobbers all their other attributes back to the default values, so may not be the best thing to do here.)
Score:0
iq flag

I've managed to make it work by editing the aaduseradd file on /etc/default and removing the # at SHELL=/bin/bash

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.