我有一台运行 Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-52-virtual x86_64) 的 amazon ec2 云服务器。我使用 bitnami 镜像安装了 gitlab。无法通过 SSH 克隆存储库。
我无法使用 ssh 密钥通过 ssh 登录为 git
➜ front-end git:(develop) ssh -vT [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to cloud.redrockrim.org [54.229.74.10] port 22.
debug1: Connection established.
debug1: identity file /Users/redrockrim/.ssh/id_rsa type 1
debug1: identity file /Users/redrockrim/.ssh/id_rsa-cert type -1
debug1: identity file /Users/redrockrim/.ssh/id_dsa type -1
debug1: identity file /Users/redrockrim/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 54:52:a4:7c:bf:45:bc:89:b5:7f:ae:59:2d:d6:e2:11
debug1: Host 'cloud.redrockrim.org' is known and matches the RSA host key.
debug1: Found key in /Users/redrockrim/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/redrockrim/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/redrockrim/.ssh/id_dsa
debug1: Next authentication method: password
[email protected]'s password:
我可以使用 ssh 以我创建的其他用户身份登录。
➜ front-end git:(develop) ssh -vT [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to cloud.redrockrim.org [54.229.74.10] port 22.
debug1: Connection established.
debug1: identity file /Users/redrockrim/.ssh/id_rsa type 1
debug1: identity file /Users/redrockrim/.ssh/id_rsa-cert type -1
debug1: identity file /Users/redrockrim/.ssh/id_dsa type -1
debug1: identity file /Users/redrockrim/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 54:52:a4:7c:bf:45:bc:89:b5:7f:ae:59:2d:d6:e2:11
debug1: Host 'cloud.redrockrim.org' is known and matches the RSA host key.
debug1: Found key in /Users/redrockrim/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/redrockrim/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to cloud.redrockrim.org ([54.229.74.10]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_IE.UTF-8
debug1: Sending env LC_CTYPE = en_IE.UTF-8
Welcome to Ubuntu 12.04.3 LTS (GNU/Linux 3.2.0-52-virtual x86_64)
___ _ _ _ _ _
| _ |_) |_| \| |__ _ _ __ (_)
| _ \ | _| .` / _` | ' \| |
|___/_|\__|_|\_\__,_|_|_|_|_|
*** Welcome to the BitNami GitLab 6.0.0-0 ***
*** BitNami Wiki: http://wiki.bitnami.com/ ***
*** BitNami Forums: http://community.bitnami.com/ ***
我可以尝试什么来解决这个问题?
答案1
可以通过在 中的密钥开头添加选项来禁用 SSH 功能authorization_keys
。这里发生的情况是,服务器阻止您的git
用户使用该特定密钥对服务器进行完全/开放访问,而只允许非常有针对性的连接……这正是您通常想要的。
如果您想以该用户的身份连接,请删除 之前的序言ssh-rsa
,尽管它的存在是有充分理由的。您仍然可以以其他用户的身份连接,su git
一旦您进入服务器...如果出于某种原因成为该用户很重要。
这些选项的含义是:
command="/opt/bitnami/apps/gitlab/gitlab-shell/bin/gitlab-shell key-3"
意味着只要建立连接就会执行此命令。 不命令可以由用户提供。
no-port-forwarding
防止 TCP 转发
no-X11-forwarding
防止 X11 转发
no-agent-forwarding
防止代理转发
no-pty
防止 TTY 分配 - 您很可能在 ssh 中使用它来在远程服务器上执行命令。
所有这些都可以在ssh(8) 手册页