[英]Github Permission denied (publickey) SSH keys in wrong directory?
I've recently installed this stack on AWS EC2: https://aws.amazon.com/marketplace/pp/B00NO1HJ56/ref=srh_res_product_title?ie=UTF8&sr=0-2&qid=1461119036279我最近在 AWS EC2 上安装了这个堆栈: https ://aws.amazon.com/marketplace/pp/B00NO1HJ56/ref=srh_res_product_title?ie = UTF8&sr = 0-2&qid =1461119036279
The instance's system log says that the SSH keys were installed here:实例的系统日志显示 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.
I have added the public key to my Github account and the fingerprints match.我已将公钥添加到我的 Github 帐户并且指纹匹配。
When cloning a repo I get: Permission denied (publickey).克隆存储库时,我得到:权限被拒绝(公钥)。
From the Github help section https://help.github.com/articles/error-permission-denied-publickey从 Github 帮助部分https://help.github.com/articles/error-permission-denied-publickey
I run: ssh -vT git@github.com and get:我运行: 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.
I seems the ssh agent is searching /home/bitnami/.ssh/ but the keys are located in /etc/ssh我似乎 ssh 代理正在搜索 /home/bitnami/.ssh/ 但密钥位于 /etc/ssh
This is the contents of /home/bitnami/.ssh这是/home/bitnami/.ssh的内容
authorized_keys
known_hosts
And this is the contents of /etc/ssh这是/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
If I check what keys are added to the ssh agent I get:如果我检查将哪些密钥添加到 ssh 代理,我会得到:
$ ssh-add -l I get:
The agent has no identities.
Is this simply a matter of adding my public key in /etc/ssh/ to the ssh agent by using ssh-add, so it knows where to look?这是否只是通过使用 ssh-add 将我在 /etc/ssh/ 中的公钥添加到 ssh 代理的问题,以便它知道在哪里查找?
I don't understand why the keys are were not installed in /etc/hosts rather than the home directory.我不明白为什么密钥没有安装在 /etc/hosts 而不是主目录中。
The solution is simply to ignore the keys in /etc/ssh.解决方案只是忽略 /etc/ssh 中的键。 These keys are used by AWS to access the instance and belongs to the system rather than a user. AWS 使用这些密钥来访问实例并且属于系统而不是用户。
So I just generated new keys for the bitnami user and those keys are now correctly sitting in /home/.ssh/所以我刚刚为 bitnami 用户生成了新密钥,这些密钥现在正确地位于 /home/.ssh/
I can now pull my repo from Github.我现在可以从 Github 中提取我的 repo。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.