大网数据广告活动
服务器运维问答

ssh root access denied after changing shell

· 52CE 我爱测

after i tried to change my server shell, i cannot login as root anymore. First, i installed the z-shell (zsh) as root and then i wanted to change it to my default shell. Therefore i used "chsh". My fault was, that i typed in a wr…

问题原文

原帖链接 · tobias b. · CC BY-SA 3.0

after i tried to change my server shell, i cannot login as root anymore.

First, i installed the z-shell (zsh) as root and then i wanted to change it to my default shell. Therefore i used "chsh". My fault was, that i typed in a wrong path. After logout and new login via Putty, i got the message "Access denied".

It was foreseeable, when the path to the shell doesn't exist. So i logged in into my control panel, and changed the /etc/passwd file via filemanager: I corrected the wrong last part of the first line - the root user:

root:x:0:0:root:/root:/usr/bin/zsh

Even if i change it to the old shell /bin/bash or /bin/sh it doesn't work. I read that passwd & shadow are no live-files, so i restarted the server, but still same problem

Any ideas, what else i could do?

OS: Debian 5 + Parallels Plesk 11

已采纳解答

原帖链接 · tobias b. · CC BY-SA 3.0

I found a solution in another Forum. For all people with the same problem, perhaps this approach can help as well:

My provider changed the root password and tried the "chsh -s /bin/bash root" which didn't work, because the password was not accepted and the following error occured: "chsh: PAM authentication failed".

dave_mystic gave the solution:

The real problem is in /etc/pam.d/chsh. In that file, the line which prevents users from changing back to a normal shell after being assigned a special shell appears before the line that authorizes all changes from the root.

Unfortunately, the following line was firing first, disallowing a change because the users shell was NOT in the list of available shells. The authorization line from me being 'root' via sudo never fired because it was never checked after the first line fired.

auth required pam_shells.so

The solution was to temporarily comment out the line in /etc/pam.d/chsh, change the users shell to the correct shell, and then remove the comment in the line.

Source: http://ubuntuforums.org/showthread.php?t=1702833

So i commented out the mentioned line and after that i was able to change the shell.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-02-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。