簡體   English   中英

Github 權限被拒絕(公鑰)SSH 密鑰在錯誤的目錄中?

[英]Github Permission denied (publickey) SSH keys in wrong directory?

我最近在 AWS EC2 上安裝了這個堆棧: https ://aws.amazon.com/marketplace/pp/B00NO1HJ56/ref=srh_res_product_title?ie = UTF8&sr = 0-2&qid =1461119036279

實例的系統日志顯示 SSH 密鑰安裝在此處:

Generating public/private rsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.

我已將公鑰添加到我的 Github 帳戶並且指紋匹配。

克隆存儲庫時,我得到:權限被拒絕(公鑰)。

從 Github 幫助部分https://help.github.com/articles/error-permission-denied-publickey

我運行: ssh -vT git@github.com 並得到:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to github.com [192.30.252.122] port 22.
debug1: Connection established.
debug1: identity file /home/bitnami/.ssh/id_rsa type -1
debug1: identity file /home/bitnami/.ssh/id_rsa-cert type -1
debug1: identity file /home/bitnami/.ssh/id_dsa type -1
debug1: identity file /home/bitnami/.ssh/id_dsa-cert type -1
debug1: identity file /home/bitnami/.ssh/id_ecdsa type -1
debug1: identity file /home/bitnami/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/bitnami/.ssh/id_ed25519 type -1
debug1: identity file /home/bitnami/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/bitnami/.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: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/bitnami/.ssh/id_rsa
debug1: Trying private key: /home/bitnami/.ssh/id_dsa
debug1: Trying private key: /home/bitnami/.ssh/id_ecdsa
debug1: Trying private key: /home/bitnami/.ssh/id_ed25519
debug1: No more authentication methods to try.

我似乎 ssh 代理正在搜索 /home/bitnami/.ssh/ 但密鑰位於 /etc/ssh

這是/home/bitnami/.ssh的內容

authorized_keys
known_hosts

這是/etc/ssh的內容

moduli
ssh_host_dsa_key
ssh_host_ecdsa_key.pub
ssh_host_rsa_key
ssh_config
ssh_host_dsa_key.pub
ssh_host_ed25519_key
ssh_host_rsa_key.pub
sshd_config
ssh_host_ecdsa_key
ssh_host_ed25519_key.pub
ssh_import_id

如果我檢查將哪些密鑰添加到 ssh 代理,我會得到:

$ ssh-add -l I get:
The agent has no identities.

這是否只是通過使用 ssh-add 將我在 /etc/ssh/ 中的公鑰添加到 ssh 代理的問題,以便它知道在哪里查找?

我不明白為什么密鑰沒有安裝在 /etc/hosts 而不是主目錄中。

解決方案只是忽略 /etc/ssh 中的鍵。 AWS 使用這些密鑰來訪問實例並且屬於系統而不是用戶。

所以我剛剛為 bitnami 用戶生成了新密鑰,這些密鑰現在正確地位於 /home/.ssh/

我現在可以從 Github 中提取我的 repo。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM