Eve*_*nça 4 windows git ssh amazon-ec2 amazon-web-services
我开始使用 Amazon EC2 服务。我已经安装了 Amazon Linux 实例、设置了 PEM 文件、打开了 SSH 端口并安装了 GIT 服务。
我的本地环境是Windows 8。
通过 putty 和 WinSCP 我可以毫无问题地连接。我已按照文档将 PEM 文件转换为 PPK,一切正常。问题是当我尝试从本地计算机执行 git Push 时。当我尝试连接时,我总是收到“权限被拒绝(公钥)”的消息。我已经使用 git bash 向 PEM 文件添加了 ssh-add,通过 GIT Bash 生成了一个自定义密钥,并将此密钥添加到了 EC2 实例的密钥部分中,但没有任何效果...
如果我尝试(使用 git bash)ssh -i 并指定 PEM 文件,我就会建立连接。
ssh -i c:/[PATH]/[PEM-FILE].pem ec2-user@[HOST].compute.amazonaws.com
Run Code Online (Sandbox Code Playgroud)
如果我尝试不带 -i,则没有连接。
$ ssh ec2-user@[HOST].compute.amazonaws.com
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
以下是使用 -vT 命令进行的跟踪:
ssh -vT ec2-user@[HOST].compute.amazonaws.com
OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
debug1: Connecting to [HOST].compute.amazonaws.com [54.201.
110.48] port 22.
debug1: Connection established.
debug1: identity file [PATH]/Usuario/.ssh/identity type -1
debug1: identity file [PATH]/Usuario/.ssh/id_rsa type 1
debug1: identity file [PATH]/Usuario/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '[HOST].compute.amazonaws.com' is known and ma
tches the RSA host key.
debug1: Found key in [PATH]/Usuario/.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: [PATH]/Usuario/.ssh/identity
debug1: Offering public key: [PATH]/Usuario/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: [PATH]/Usuario/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
那么,有没有一种方法可以通过 SSH 连接而不需要 -i 选项?
经过几次尝试,我在这里找到了一篇包含一些说明的文章https://serverfault.com/questions/194567/how-do-i-tell-git-for-windows-where-to-find-my-private-rsa-钥匙
我按照以下步骤操作:“在拥有主目录及其下的 .ssh 文件夹后,您需要打开 PuTTYgen 并打开您之前创建的密钥(.ppk 文件)。打开密钥后,您需要选择转换 -> 导出 OpenSSH 密钥并将其保存到 HOME.ssh\id_rsa。在该位置获得密钥后,Git bash 将识别该密钥并使用它”
| 归档时间: |
|
| 查看次数: |
4421 次 |
| 最近记录: |