简体   繁体   English

Github 权限被拒绝(公钥)SSH 密钥在错误的目录中?

[英]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.

相关问题 将SSH密钥添加到authorized_keys:权限被拒绝(publickey) - Adding SSH Key to authorized_keys: permission denied(publickey) ssh/scp - 权限被拒绝(公钥、密码) - Ssh/scp - Permission denied (publickey,password) AWS_EC2 ssh 权限被拒绝(公钥) - AWS_EC2 ssh Permission denied (publickey) ssh 无密码登录失败,权限被拒绝(公钥) - ssh passwordless login fails with permission denied (publickey) 使用ssh从github部署到linux服务器,但是权限被拒绝(公钥)。 PHP脚本 - deploying from github to linux server using ssh but Permission denied (publickey). PHP script 从 ec2 到 github 的权限被拒绝(公钥) - Permission denied (publickey) from ec2 to github 无法通过 SSH 连接到远程 Amazon 实例(权限被拒绝(公钥)) - Not able to connect to remote Amazon Instance via SSH (Permission denied(publickey)) 启动 SSH session 权限被拒绝(公钥)时出错 - Getting error while launching a SSH session Permission denied (publickey) 尝试通过SSH进入Amazon EC2时出现“权限被拒绝(公钥)。” - “Permission denied (publickey).” while trying to SSH into Amazon EC2 Capistrano 3 部署无法连接到 GitHub - 权限被拒绝(公钥) - Capistrano 3 deploy fails connecting to GitHub - Permission denied (publickey)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM