【发布时间】:2017-06-22 16:53:46
【问题描述】:
我在 gitlab 上有一个项目,我正在尝试向其推送提交。我首先使用 https url 克隆了该项目,然后将其更改为 ssh,然后运行cat ~/.ssh/id_rsa.pub,这给了我 ssh 密钥:我已将密钥复制粘贴到我的 gitlab 配置文件中的 ssh 密钥,但尝试推送我收到一条消息的提交:
无法确定主机“gitlab”的真实性。 RSA 密钥 指纹为 SHA256:cZiqgz2tMzLXftNIIXmQ9v+6M38xM1LzxROnDM1OJ0Q。 您确定要继续连接(是/否)?是的 警告:将 '07.no, 'myIpAddress' (RSA) 永久添加到已知主机列表中。 权限被拒绝(公钥)。
正在运行ssh -Tv git@myEmail:
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to myEmail [myIpAddress] port 22.
debug1: Connection established.
debug1: identity file /Users/myUser/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/myUser/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-9etch3
debug1: match: OpenSSH_4.3p2 Debian-9etch3 pat OpenSSH_4* compat 0x00000000
debug1: Authenticating to myEmail:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha1
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<7680<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:Wcsi4VBAIf2M+M62Gx16W2yCR8rbtm9yh/WiQRe707o
debug1: Host 'myEmail' is known and matches the RSA host key.
debug1: Found key in /Users/myUser/.ssh/known_hosts:2
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/myUser/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/myUser/.ssh/id_dsa
debug1: Trying private key: /Users/myUser/.ssh/id_ecdsa
debug1: Trying private key: /Users/myUser/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
我该如何解决这个问题?
【问题讨论】:
-
好的,所以当@Rohit Poudel 正确回答时,它都会警告您正在连接的新主机,但在您的编辑中它还显示“权限被拒绝(公钥)”,这表明密钥无法识别由 GitLab 提供。您确定 repo 在您的用户帐户下,您可能还添加了 SSH 密钥?
-
也只是为了确认一下,如果您运行
git remote -v,它是否显示:origin git@gitlab.com:your_user_account/your_repo而不是对https的任何引用? -
它显示 git@gitlab
-
Stack Overflow 是一个编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参阅帮助中心的What topics can I ask about here。也许Super User 或Unix & Linux Stack Exchange 会是一个更好的提问地点。