SSH身份验证失败:权限被拒绝(publickey)

时间:2016-06-16 15:08:02

标签: git jenkins ssh public-key

我有一个特定的背景。我想把Jenkins绑定到Git。 Jenkins在Tomcat上运行,我使用Docker容器来运行Git Server(https://hub.docker.com/r/unixtastic/git-ssh-server

问题是Jenkins无法连接到Git。所以,为了确定故障排除,我首先尝试在命令行中连接到Git Server throw ssh:

$ ssh git@172.17.0.2

连接成功,我可以登录到Git Server。但它与登录/密码有关。但我想用公钥来做。

因此,当我在Git Server sshd_config文件中禁用登录/密码登录时,现在登录失败,除非我认为我的配置是正确的:

  1. 我用ssh-keygen创建了一对密钥。此密钥位于客户端/home/git/.ssh
  2. 我在Git用户的主目录下复制了Git Server上的公钥:/git/.ssh/authorized_keys
  3. 尝试登录
  4. 后,服务器公钥在客户端用户的known_hosts文件中很好地复制

    但不幸的是,登录失败并显示完整的消息:

    OpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips  1 Mar 2016
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to 172.17.0.2 [172.17.0.2] port 22.
    debug1: Connection established.
    debug1: identity file /home/git/.ssh/id_rsa type 1
    debug1: key_load_public: No such file or directory
    debug1: identity file /home/git/.ssh/id_rsa-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1
    debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7
    debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.7 pat OpenSSH_6.6.1* compat 0x04000000
    debug1: Authenticating to 172.17.0.2:22 as 'git'
    debug1: SSH2_MSG_KEXINIT sent
    debug1: SSH2_MSG_KEXINIT received
    debug1: kex: algorithm: curve25519-sha256@libssh.org
    debug1: kex: host key algorithm: ssh-rsa
    debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ssh-rsa SHA256:103879AadyMX3oJAuSWHR74aQhBaZIg3yb95v6/FyeI
    debug1: Host '172.17.0.2' is known and matches the RSA host key.
    debug1: Found key in /home/git/.ssh/known_hosts:1
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS sent
    debug1: expecting SSH2_MSG_NEWKEYS
    debug1: rekey after 134217728 blocks
    debug1: SSH2_MSG_NEWKEYS received
    debug1: SSH2_MSG_SERVICE_ACCEPT received
    debug1: Authentications that can continue: publickey
    debug1: Next authentication method: publickey
    debug1: Offering RSA public key: /home/git/.ssh/id_rsa
    debug1: Authentications that can continue: publickey
    debug1: No more authentication methods to try.
    Permission denied (publickey).
    

0 个答案:

没有答案