错误密码:chsh:PAM:尝试安装时验证失败 Oh my zsh

UmA*_*orn 11 command-line bash authentication zsh

我尝试安装哦我的 zsh。安装 zsh ( sudo apt-get update && sudo apt-get install -y zsh) 后

然后我安装

sudo apt-get install -y curl  
Run Code Online (Sandbox Code Playgroud)

然后安装git。

当我尝试此命令时会出现问题。

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | bash
Run Code Online (Sandbox Code Playgroud)

这是日志

sudo curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   146  100   146    0     0     91      0  0:00:01  0:00:01 --:--:--    91
100  1779  100  1779    0     0    525      0  0:00:03  0:00:03 --:--:--  1416
\033[0;34mCloning Oh My Zsh...\033[0m
Cloning into '/home/icom3/.oh-my-zsh'...
remote: Reusing existing pack: 10101, done.
remote: Total 10101 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (10101/10101), 1.92 MiB | 172.00 KiB/s, done.
Resolving deltas: 100% (5337/5337), done.
Checking connectivity... done.
\033[0;34mLooking for an existing zsh config...\033[0m
\033[0;33mFound ~/.zshrc.\033[0m \033[0;32mBacking up to ~/.zshrc.pre-oh-my-zsh\033[0m
\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m
\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m
\033[0;34mTime to change your default shell to zsh!\033[0m
Password: chsh: PAM: Authentication failure
Run Code Online (Sandbox Code Playgroud)

有什么想法吗?

请注意,我已经尝试过

sudo vim /etc/pam.d/chsh  
Run Code Online (Sandbox Code Playgroud)

然后评论 auth required pam_shells.so。但是,错误仍然发生。

Ada*_*hon 16

单独下载并运行脚本:

curl -OL https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
bash install.sh
Run Code Online (Sandbox Code Playgroud)

您可能应该撤消对/etc/pam.d/chsh.

解释:

将脚本的文本通过管道传输到 bash

cat script.sh | bash
Run Code Online (Sandbox Code Playgroud)

与将脚本作为参数提供给 bash

bash script.sh
Run Code Online (Sandbox Code Playgroud)

通过管道install.shbash,bash从管道而不是用户获取其标准输入(stdin)。在这种情况下,chsh似乎也从stdin接收其输入,这是脚本中调用chsh. (目前它似乎是一个空行。如果它是你的密码,你就不会有任何问题;-))

您可以使用这个简短的脚本进行测试,其中read需要一行输入:

read -p 'input: ' INPUT
echo -n 'You wrote this: '
echo "> $INPUT <"
Run Code Online (Sandbox Code Playgroud)

保存为script.sh

$ bash script.sh
input: foobar
You wrote this: > foobar <
$ cat script.sh | bash
> echo -n 'You wrote this: ' <
Run Code Online (Sandbox Code Playgroud)

  • 伟大的诊断。我在 Debian 上遇到了同样的问题,你的修复对我有用。在 oh-my-zsh 项目(https://github.com/robbyrussell/oh-my-zsh/issues/3516)上有几个未解决的问题,所以希望这也能在上游得到修复。顺便说一句,小吹毛求疵:`curl` 将文件打印到标准输出,而不是像 `wget` 那样写入文件;您需要在命令末尾使用 `curl -L ... &gt; install.sh` 重定向。 (2认同)