2017-06-22 116 views
-1

我在gitlab上有一個項目,我試圖推送一個提交。我首先用https url複製了項目,但之後將其改爲ssh,然後運行cat ~/.ssh/id_rsa.pub,它給了我ssh密鑰:我有拷貝將密鑰粘貼到我的gitlab配置文件中的ssh密鑰,但嘗試推送提交我收到一條消息:無法與gitlab建立ssh連接

主機'gitlab'的真實性無法建立。 RSA密鑰 指紋是SHA256:cZiqgz2tMzLXftNIIXmQ9v + 6M38xM1LzxROnDM1OJ0Q。 您確定要繼續連接(是/否)嗎?是 警告:將'07 .no,'myIpAddress'(RSA)永久添加到已知主機列表中。 權限被拒絕(公鑰)。

在運行ssh -Tv [email protected]

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). 

我該如何解決呢?

+0

好的,所以它都會警告你正在連接的新主機,正如@Rohit Poudel正確回答的一樣,但是在你的編輯中還會顯示「Permission denied(publickey)」,暗示GitLab無法識別該密鑰。您確定回購站位於您的用戶帳戶下,您大概還添加了您的SSH密鑰? – roryrjb

+0

也只是爲了確認,如果你運行'git remote -v',它是否顯示:'origin \t [email protected]:your_user_account/your_repo'而不是任何對'https'的引用? – roryrjb

+0

它顯示git @ gitlab – Leff

回答

-1

它告訴你,你從來沒有連接到這臺服務器。如果你期待這一點,這是非常正常的。如果您偏執,請使用備用渠道驗證密鑰的校驗和/指紋。 (但是請注意,有人可以重定向您的ssh連接,也可以重定向Web瀏覽器會話。)

如果您在從此安裝ssh之前已連接到此服務器,則服務器已用新密鑰重新配置或者某人在欺騙服務器的身份。由於中間人攻擊的嚴重性,它警告你可能性。

無論哪種方式,你都有一個安全的加密頻道給某人。沒有人沒有與指紋相對應的私鑰可以解碼您發送的內容。

您用來驗證自己身份的密鑰是無關的......您不希望將身份驗證信息發送給可能會竊取該密碼的欺詐服務器,因此您不應該期待任何更改,具體取決於您是否要使用密碼或私鑰進行登錄。你在這個過程中還沒有那麼遠。

+0

是的,我以前沒有嘗試過連接,這是我第一次,但是,因爲這個,我無法推送任何東西,我該如何解決這個問題? – Leff