使用 AAD 登录在 Azure Linux VM 上设置默认 shell?

使用 AAD 登录在 Azure Linux VM 上设置默认 shell?

我正在使用新的 Azure Active Directory(“AAD”)登录机制登录 Azure 环境中的 Azure Ubuntu Linux VM,我想更改用户的默认 shell。通常使用chsh -s.chsh 执行的操作对我来说不起作用,我想知道在这种情况下我应该做什么。有人知道如何更改 Linux VM 上 AAD 身份验证帐户的默认 shell 吗

我和我工作中的其他一些用户希望将他们的默认 shell 从 bash 更改为 zsh,因为我们更喜欢使用 zsh 进行交互式使用。

这是我尝试使用chsh -s(已编辑)时看到的内容。

[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"

这是 Azure 上的 Linux VM,它是从“Ubuntu Server 20.04 LTS”映像创建的,然后使用它进行升级do-release-upgrade,或者从“Ubuntu Server 22.04 LTS”映像创建的;我不记得是哪一个了。

如果我使用 OpenLDAP,LDAP 目录中有一个地方可以根据每个用户设置默认 shell。但我在 Azure Active Directory 中没有看到类似的东西。

我正在使用此处描述的“新” Azure AD Linux 身份验证机制 -https://learn.microsoft.com/en-us/azure/active-directory/devices/howto-vm-sign-in-azure-ad-linux- 而不是这里描述的旧的、已弃用的 -https://learn.microsoft.com/en-us/previous-versions/azure/virtual-machines/linux/login-using-aad。上面显示的“设备登录”对话框是对chsh远程 Linux VM 上的响应,而不是首先用于通过 SSH 登录该框的交互式键盘登录过程的一部分。

我不想做那种草率的 hack,exec zsh在文件底部直接抛出一个调用~/.bashrc。如果你这样做,那么就很难运行交互式 bash,我们有理由这样做,以便进行测试和代码共享等等,即使我们更喜欢在大多数交互式 shell 场景中使用 zsh。

答案1

/etc/aadpasswd您需要以而不是为目标的工具/etc/passwd- 当添加 AAD 登录扩展时,您将安装该扩展,如果您具有 root 访问权限,则aaduseradd可以通过该扩展设置您的 shell 。sudo aaduseradd $USER -s <new shell>

遗憾的是,没有chsh安装等效程序,因此您需要具有 root 权限的人来更改您的 shell。

答案2

我已设法通过编辑 /etc/default 上的 aaduseradd 文件并删除 SHELL=/bin/bash 处的 # 来使其工作

相关内容