Linux 权限被拒绝(公钥)Git和AWS EC2

Linux 权限被拒绝(公钥)Git和AWS EC2,linux,git,ssh,amazon-ec2,Linux,Git,Ssh,Amazon Ec2,有许多与此授权问题相关的类似问题和答案---“拒绝许可(公钥)”。然而,它们都不能解决我的问题 以下是我的情况:我使用的是AmazonWebServerEC2,我的电脑与服务器连接良好。下一步,我尝试在服务器上安装git。我希望实现的结果是在从本地推送时更新服务器端。但问题出现了:“权限被拒绝(公钥)” OpenSSH_6.9p1,LibreSSL 2.1.8 debug1:正在读取配置数据/Users/IvyLin/.ssh/config debug1:读取配置数据/etc/ssh/ssh\u

有许多与此授权问题相关的类似问题和答案---“拒绝许可(公钥)”。然而,它们都不能解决我的问题

以下是我的情况:我使用的是AmazonWebServerEC2,我的电脑与服务器连接良好。下一步,我尝试在服务器上安装git。我希望实现的结果是在从本地推送时更新服务器端。但问题出现了:“权限被拒绝(公钥)”

OpenSSH_6.9p1,LibreSSL 2.1.8 debug1:正在读取配置数据/Users/IvyLin/.ssh/config debug1:读取配置数据/etc/ssh/ssh\u config debug1:/etc/ssh/ssh\u配置第21行:应用* debug1:/etc/ssh/ssh\u配置第56行:应用* debug1:连接到52.68.24.4[52.68.24.4]端口22。 debug1:已建立连接。 debug1:identity file/Users/IvyLin/.ssh/id\u rsa类型1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id\u rsa-cert类型-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_dsa type-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_dsa-cert type-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_ecdsa type-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_ecdsa-cert type-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_ed25519 type-1 debug1:key\u load\u public:没有这样的文件或目录 debug1:identity file/Users/IvyLin/.ssh/id_ed25519-cert type-1 debug1:启用协议2.0的兼容模式 debug1:本地版本字符串SSH-2.0-OpenSSH_6.9 debug1:远程协议版本2.0,远程软件版本OpenSSH_6.6.1 debug1:匹配:OpenSSH_6.6.1 pat OpenSSH_6.6.1*compat 0x04000000 debug1:将52.68.24.4:22验证为“git” debug1:SSH2\u MSG\u KEXINIT已发送 debug1:SSH2\u MSG\u KEXINIT已收到 debug1:kex:server->client chacha20-poly1305@openssh.com没有一个 debug1:kex:client->server chacha20-poly1305@openssh.com没有一个 debug1:需要SSH2\u MSG\u KEX\u ECDH\u回复 debug1:服务器主机密钥:ecdsa-sha2-nistp256 SHA256:ieQEskLZ3tiW76F5KPhlQfHcGYFW+SifiIDQnBUZHmY debug1:主机“52.68.24.4”已知并与ECDSA主机密钥匹配。 debug1:在/Users/IvyLin/.ssh/known_hosts:5中找到密钥 debug1:SSH2\u MSG\u已发送新密钥 debug1:应为SSH2\u MSG\u NEWKEYS debug1:SSH2\u MSG\u接收到新密钥 debug1:SSH2\u消息\u服务\u请求已发送 debug1:SSH2\u消息\u服务\u接收 debug1:可以继续的身份验证:公钥 debug1:下一个身份验证方法:公钥 debug1:提供RSA公钥:/Users/IvyLin/.ssh/id\u RSA debug1:可以继续的身份验证:公钥 debug1:提供RSA公钥:/Users/IvyLin/.ssh/id\u RSA debug1:可以继续的身份验证:公钥 debug1:尝试私钥:/Users/IvyLin/.ssh/id\u debug1:正在尝试私钥:/Users/IvyLin/.ssh/id\u ecdsa debug1:正在尝试私钥:/Users/IvyLin/.ssh/id\u ed25519 debug1:不再尝试验证方法。 权限被拒绝(公钥)。 我想知道的一件事是我应该把公钥放在哪里?服务器中已经有一个用于“验证服务器连接”的.ssh文件,路径:
~/.ssh
,它对我有效。 关于git的ssh密钥,我在git文件夹中创建了另一个.ssh文件夹,路径:
~/home/git/.ssh
。它在连接过程中查找哪个文件?虽然我已经尝试将公钥放入
~/.ssh
,但它仍然不起作用

我被困在那里太久了,如果有人能帮助我,我真的很感激!实现“推送更新”的变通方法也将帮助我解决问题

我想知道的一件事是我应该把公钥放在哪里

您必须将git服务器上的公钥放在您的帐户下

它在连接过程中查找哪个文件


您必须将
~/.ssh/id\u rsa.pub
复制到您的git服务器帐户

您好!谢谢你的回复!我已将公钥放入服务器端的“~/.ssh/authorized_keys”中,但仍然会出现错误。。。还有其他可能出错的地方吗?实际上,如果两个密钥都应该放在服务器帐户下,这是否意味着它们可以合并为一个?或者我们需要配置文件来区分它们。。。我感到困惑…您需要区分并使用配置文件包含您的密钥的文件名是什么?要在服务器端存储公钥,在您的本地计算机中,它是“~/.ssh/authorized_keys”@JakujeNo。如果您自己将其存储在服务器上,请确保
ls-l~~/.ssh~/.ssh/authorized_keys
上的权限。
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/IvyLin/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug1: Connecting to 52.68.24.4 [52.68.24.4] port 22.
debug1: Connection established.
debug1: identity file /Users/IvyLin/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/IvyLin/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 52.68.24.4:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:ieQEskLZ3tiW76F5KPhlQfHcGYFW+SifiIDQnBUZHmY
debug1: Host '52.68.24.4' is known and matches the ECDSA host key.
debug1: Found key in /Users/IvyLin/.ssh/known_hosts:5
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: Offering RSA public key: /Users/IvyLin/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /Users/IvyLin/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/IvyLin/.ssh/id_dsa
debug1: Trying private key: /Users/IvyLin/.ssh/id_ecdsa
debug1: Trying private key: /Users/IvyLin/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).