我正试图让gitolite工作并且被困住了几个小时。我局域网上的CentOS 6服务器。
我终于让ssh -vvv gitolite
使用此配置文件
Host gitolite
User gitolite
HostName srv
Port 2002
IdentityFile ~/.ssh/srv_gitolite_openssh
但是只有当我在服务器上执行此操作才能进行调试
sudo service sshd stop
sudo /usr/sbin/sshd -Dd
当sshd作为服务运行时,连接失败。
为什么我手动运行sshd时有效,但sshd不作为服务?它似乎使用相同的sshd_config
文件,因为它使用相同的端口号。另外,我的用户名gitolite
位于配置的AllowUsers
部分。
成功案例如下:
更新:以下是服务器端日志
作为服务失败:http://pastebin.com/Xce2k2x5
成功:http://pastebin.com/jYgiDhEm
失败案例的亮点如下。在这两种情况下,“key_from_blob”不应该相同吗?我已经尝试删除authorized_keys的命令部分,它仍然作为服务失败。
debug3: mm_answer_keyallowed entering
debug3: mm_answer_keyallowed: key_from_blob: 0x7f72b6e93350
debug1: temporarily_use_uid: 505/505 (e=0/0)
debug1: trying public key file /var/lib/gitolite/.ssh/authorized_keys
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 505/505 (e=0/0)
debug1: trying public key file /var/lib/gitolite/.ssh/authorized_keys2
debug1: restore_uid: 0/0
Failed publickey for gitolite from 192.168.1.201 port 57488 ssh2
debug3: mm_answer_keyallowed: key 0x7f72b6e93350 is not allowed
debug3: mm_request_send entering: type 22
成功案例的重点:
debug3: mm_answer_keyallowed entering
debug3: mm_answer_keyallowed: key_from_blob: 0x7f4d79de18b0
debug1: temporarily_use_uid: 505/505 (e=0/0)
debug1: trying public key file /var/lib/gitolite/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug3: secure_filename: checking '/var/lib/gitolite/.ssh'
debug3: secure_filename: checking '/var/lib/gitolite'
debug3: secure_filename: terminating check at '/var/lib/gitolite'
debug2: key_type_from_name: unknown key type 'command="/var/lib/gitolite/bin/gitolite-shell'
debug3: key_read: missing keytype
debug2: user_key_allowed: check options: 'command="/var/lib/gitolite/bin/gitolite-shell gitolite",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBrEOo5blAUXXSwXdxUxTOhBDHcjw2OzxGg6Vu4drzmUYL5uPxjWLGzuzcNkrYmlVqXr5UBqeSbkZh9W/0lLMcmiv5FLdIQ+J2m5lqHsEJLS8FImfJxfo2/LvboFy0NFOxF8GaHxeIWFp+YmwAlogO9gi1zgXK99DGc15W/edYwCw==
'
debug1: matching key found: file /var/lib/gitolite/.ssh/authorized_keys, line 2
Found matching RSA key: ae:92:1d:a7:7b:ec:75:7a:19:ac:28:75:b0:cc:27:8f
debug1: restore_uid: 0/0
debug3: mm_answer_keyallowed: key 0x7f4d79de18b0 is allowed
答案 0 :(得分:1)
我怀疑钥匙在这两种情况下都有效。
但是,将sshd
作为服务运行与从当前会话运行它不同:请参阅“Why would I use “service sshd reload
” in preference to “service sshd restart
”?”。
该服务取消所有继承的环境变量,并仅保留PATH
和TERM
。
~gitolite/.ssh/authorized_keys
中注册了Gitolite uses a forced command,并且必须缺少一个环境变量(当sshd作为服务运行时),这会阻止执行该命令。
“public key authentication fails ONLY when sshd is daemon”有类似的情况:
SELinux可能是原因
.ssh
目录可能是错误标记的。看看
/var/log/audit/audit.log
。它应标记为ssh_home_t
如果需要,请查看ls -laZ. Run restorecon -r -vv /root/.ssh
。