14.04 不对 chsh 命令进行身份验证

RCF*_*RCF 5 command-line pam chsh 14.04

我正在尝试将我的默认 shell 更改为 zsh。我将条目正确放置在 /etc/shells 文件中。

我使用此命令所做的每次尝试都以相同的错误消息结束:

chsh -s $(which zsh)
Password: ### after entering the correct password
chsh: PAM: Authentication failure

sudo chsh -s $(which zsh) ## yields the same result
Run Code Online (Sandbox Code Playgroud)

我已将 sudo 用于其他命令,以确保它不是密码失败,并且所有其他命令都有效,但对“chsh”不起作用。

完全被难住了。

附加信息:

我已经按照 Oli 的建议代码在 /etc/shells 文件中附加了一行。

echo $SHELL 
/bin/bash

sudo chsh -s /usr/local/bin/zsh
Password:
chsh: PAM: Authentication failure

chsh -s /usr/local/bin/zsh
You may not change the shell for 'username'
Run Code Online (Sandbox Code Playgroud)

还是不能换壳。

Oli*_*Oli 7

PAM 对chsh. 正如你所看到的 form /etc/pam.d/chsh,它正在做一个检查:

# This will not allow a user to change their shell unless
# their current one is listed in /etc/shells. This keeps
# accounts with special shells from changing them.
auth       required   pam_shells.so
Run Code Online (Sandbox Code Playgroud)

此检查还有一个手册页 ( man pam_shells) 告诉我们以下内容:

pam_shells is a PAM module that only allows access to the  system if the users shell is 
listed in /etc/shells.

It also checks if /etc/shells is a plain file and not world writable.
Run Code Online (Sandbox Code Playgroud)

因此,根据它的声音,您/usr/bin/zsh/etc/shells. 让我们添加一个:

echo $(which zsh) | sudo tee -a /etc/shells
chsh -s $(which zsh)
Run Code Online (Sandbox Code Playgroud)

那里没有列出那个或您当前的外壳。如果您遇到类似的问题rbash,那可能不是列出的示例,并且可能会阻止您更改 shell。

我测试了(zsh从 中删除了行/etc/shells,加载zsh并尝试chsh)但看到了一个非常不同的错误消息:

You may not change the shell for 'oli'
Run Code Online (Sandbox Code Playgroud)

所以应该不是这个。