2014-03-06 252 views
9

我正在尝试为Phabricator配置SSH以使git运行。我跟着这manual,但当我打电话echo {} | ssh [email protected] conduit conduit.ping我总是得到一个空的结果或Permission denied (publickey,keyboard-interactive).使用SSH为Phabricator配置Git

/etc/ssh-phabricator/sshd_config

AuthorizedKeysCommand /usr/libexec/ssh-phabricator-hook 
AuthorizedKeysCommandUser git 

Port 22 
Protocol 2 
PermitRootLogin no 
AllowAgentForwarding no 
AllowTcpForwarding no 
PrintMotd no 
PrintLastLog no 
PasswordAuthentication no 
AuthorizedKeysFile none 

/etc/passwd

phd:x:999:999::/var/tmp/phd:/bin/false 
git:x:1005:1005::/home/git:/bin/bash 

/etc/shadow

phd:!:16135:::::: 
git:NP:16135:0:99999:7::: 

/etc/sudoers

git ALL=(phd) SETENV: NOPASSWD: /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /bin/false 

~/.ssh/config

Host phabricator.mydomain.com 
    HostName phabricator.mydomain.com 
    Port 22 
    IdentityFile /c/Users/.../.ssh/id_rsa_phabricator 
    PreferredAuthentications publickey 
    User git 

UPDATE

我的问题的原因是:

  • 我没有在客户端使用SSH密钥。
  • 我没有确保git用户有一个shell。
+2

https://secure.phabricator.com/T4151中的部分信息尚未提供给主要文档,但可能会有所帮助。特别是,检查你的'git'用户''/ etc/shadow'中是否有'NP'(而不是''')和'/ bin/sh'(而不是'/ bin/false')这样的真实shell。 –

+0

谢谢!这应该是文档的一部分。 – witrin

回答

2

你的ssh钩子工作正常 - 首先,你应该确保git ssh用户能够ssh到正常的ssh守护进程 - 这将确保你可以用这个用户登录。

更多可能你有一个坏的主目录或坏评论所述的shell。

如果所有这些工作正常,请确保您已将ssh密钥上传到您的配置文件,并且您正在使用此密钥进行连接。

3

只是还有一点要注意的是,路径必须具有正确的权限为AuthorizedKeysCommand或者,这也可能导致

Permission denied (publickey,keyboard-interactive) 
0

我跑进

Permission denied (publickey,keyboard-interactive) 

的问题太多,发现另一个原因这里还没有提到:SELinux。

如果您在服务器上使用带有“强制”策略的SELinux,则可能会遇到同样的问题。要检查SELinux的负责,设置

$ setenforce 0 

,并再次尝试

$ echo {} | ssh [email protected] conduit conduit.ping 

如果它突然的作品,但你不想永久禁用SELinux或许可模式下运行它,你可以使用audit2allow解决您的服务器最近遇到的问题:

$ ausearch -m avc -ts recent | audit2allow -M local 
$ semodule -i local.pp 

这ausearch将打印SELinux日志(通常为/var/log/audit/audit.log)中的最新条目,audit2allow将为标记为的条目创建策略,否认。 确保日志中没有最近没有您不想允许的条目。