git ssh:用户不允许的外壳不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18896825/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:04:37  来源:igfitidea点击:

ssh: User not allowed shell does not exist

linuxgitshellssh

提问by Webconstructor

  • Apache
  • CentosOS 5
  • Plesk 10
  • 阿帕奇
  • CentosOS 5
  • Plesk 10

New on commandline and ssh.

命令行和 ssh 上的新内容。

While trying to get several users (root git friend) to ssh to the same shell and configuring passwordless connection I must have made a mistake.

在尝试让多个用户(root git 朋友)通过 ssh 连接到同一个 shell 并配置无密码连接时,我一定犯了一个错误。

I can no longer login over ssh as rootor git but can as friend whose shell I transferred by editting etc/passwd. I luckily can still login on plesk so gui file editing is possible.

我不能再以 root或 git身份通过 ssh 登录,但可以作为我通过编辑 etc/passwd 传输的 shell 的朋友。幸运的是,我仍然可以登录 plesk,因此可以编辑 gui 文件。

here's what I found in my sshd errorlog

这是我在 sshd 错误日志中发现的内容

sshd[11999]: User git not allowed because shell /bin/bash\r does not exist
sshd[12000]: input_userauth_request: invalid user git
sshd[11999]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=xxx.xxx.xxx.dynamic.upc.nl  user=git
sshd[11999]: Failed password for invalid user git from xxx.xxx.xxx port 54851 ssh2

I read something about sudo ing and incidently entering: causing the \r But where to restore? Here are some configurations

我读了一些关于 sudo ing 并偶然输入的内容:导致 \r 但是在哪里恢复?这里有一些配置

etc/ssh/sshd_config :

etc/ssh/sshd_config :

PubkeyAuthentication yes

ect/shells

等/贝壳

/bin/sh
/bin/bash
/sbin/nologin
/bin/tcsh
/bin/csh
/bin/false
/usr/local/psa/bin/chrootsh
/bin/rbash

etc/passwd

等/密码

git:x:10009:10009::/home/git:/bin/bash
friend:x:10010:10010::/home/git:/bin/bash

earlier I tried to install password less connecting so there is a .ssh/id_rsa file somewhere on the server and on my local machine.

早些时候,我尝试安装无密码连接,因此在服务器和本地计算机上的某处有一个 .ssh/id_rsa 文件。

After reading Git's famous "ERROR: Permission to .git denied to user"

阅读Git 著名的“ERROR: Permission to .git denied to user”后

I tried

我试过

ssh-add -l
Could not open a connection to your authentication agent

My problem resembles this: https://serverfault.com/questions/480806/ssh-root-access-denied-after-changing-shell

我的问题类似于:https: //serverfault.com/questions/480806/ssh-root-access-denied-after-changed-shell

If I am logged over ssh as friend I cannot sudo to root:

如果我以朋友身份通过 ssh 登录,则无法使用 sudo 来 root:

sudo root 
friend is not in the sudoers file

nor can I chsh

我也不能chsh

[friend@vpsXXX ~]$ chsh -s /bin/bash root
chsh: Running UID doesn't match UID of user we're altering, shell change denied

Hope someone can clear this up for me.

希望有人能帮我解决这个问题。

Happy to supply more info if needed

如果需要,很乐意提供更多信息

回答by hek2mgl

/bin/bash\r

means that you've edited the /etc/passwd or /etc/shells with a Windows editor as it contains Windows line feeds \r\n. Linux interprets only the \nand assumes that the remaining \ris part of the binary name.

意味着您已经使用 Windows 编辑器编辑了 /etc/passwd 或 /etc/shells,因为它包含 Windows 换行符\r\n。Linux 仅解释\n并假定其余\r部分是二进制名称的一部分。

Solution: Open the files in a Linux editor and remove the new line and add it again.

解决方案:在 Linux 编辑器中打开文件并删除新行并重新添加。

Also you could install the package tofrodosand execute:

您也可以安装软件包tofrodos并执行:

fromdos /etc/passwd
fromdos /etc/shells