chsh always asking a password , and get `PAM: Authentication failure`
Matthew Martinez
Today I tried to switch to another shell.
First I tried fish, and used chsh -s fish to change fish to default. After some time I found it cannot use ~/.bashrc (&& needs to be replaced by and).
Because I prefer to reusing ~/.bashrc, I found zsh which seems an easier one and followed this documentation to switch to zsh.
While I was running sh -c "$(curl -fsSL )", suddenly it asked me to enter Password:. I entered the root password but got PAM: Authentication failure.
Then I tried chsh -s bash and chsh -s zsh, it always asked me for a password and threw PAM: Authentication failure (not system password). I can't figure this out.
8 Answers
Thanks to this question on Server Fault, I worked around this by:
Changing /etc/pam.d/chsh: from:
auth required pam_shells.soto
auth sufficient pam_shells.soThen it doesn't ask for a password anymore. But I think it better to restore chsh settings after switching the shell.
2Try this:
sudo chsh -s $(which zsh) $(whoami) 1 Use
which zshto find yourzshlocation.$ which zsh /usr/bin/zshAdd
/usr/bin/zshto/etc/shellsCheck in
/etc/passwdthat your config is/usr/bin/zshRun
chsh -s /usr/bin/zsh
An alternate work around –
My /etc/pam.d/chsh file has this section:
# This allows root to change user shell without being
# prompted for a password
auth sufficient pam_rootok.soAs the comment suggests, it lets root change the shell without needing to product the password. As such I was able to change my shell (to zsh) by running chsh as root and specifying my user account, eg:
sudo chsh $USER -s $(which zsh) 1 Try adding at bottom of your $HOME/.bashrc
export SHELL=`which sh`
zsh
exitThis works for me! if you want you can put a welcome text in your shell, but you must install figlet using:
sudo apt install figletAnd overwrite the previous code at bottom of your $HOME/.bashrc
export SHELL=`which zsh`
figlet 'Your welcome message LIKE FOR ME: Welcome'
zsh
exit For those for whom the top two solutions did not work. I've found my solution here:
There is a workaround for
gnome-terminal:
- Go to Edit → Profile preferences → Title and Command.
- Check Run a custom command instead of my shell.
- Provide
bashas the Custom command (orfish, or anything).
I had this issue when switching to fish. I accidentally executed chsh -s /usr/local/bin/fish while on my system it should have been chsh -s /usr/bin/fish, but even though the first command warned that the shell did not exist, it still changed it to /usr/local/bin/fish in /etc/passwd. This meant that the second, correct, command failed to authenticate (just like new SSH logins) as the shell did not exist.
The solution for me was to first correct the shell to an existing one in /etc/passwd, and then run the correct chsh command again.
This is my solution:
grep -qxF "$(which zsh)" "/etc/shells" || sudo bash -c "echo $(which zsh) >> /etc/shells"
grep -qxF "$(which zsh)" "/etc/shells" && sudo chsh -s "$(which zsh)" "$(whoami)"- Check whether
/etc/shellscontains thezshexecutable you want. If it doesn't, append it to the file. - If
/etc/shellscontains the shell you want, change your user's shell to that.
I have some parts abstracted into variables but for simplicity's sake, I included the full logic as plainly as possible.