簡體   English   中英

在Windows 8上拒絕使用SSH連接到Amazon EC2的權限

[英]Permission denied to connect to Amazon EC2 using SSH at Windows 8

我開始使用Amazon EC2服務。 我已經安裝了一個Amazon Linux實例,設置了PEM文件,打開了SSH端口並安裝了GIT服務。

我的本地環境是Windows 8。

通過膩子和WinSCP,我可以毫無問題地進行連接。 我已經按照文檔進行操作,並將我的PEM文件轉換為PPK,並且一切正常。 問題是當我嘗試從本地計算機執行git push時。 當我嘗試連接時,總是會得到“權限被拒絕(公共密鑰)”。 我已經使用git bash將ssh-add添加到PEM文件,通過GIT Bash生成了一個自定義密鑰,並將此密鑰添加到EC2實例的密鑰參數中,但沒有任何效果...

如果我嘗試(使用git bash)ssh -i並指定PEM文件,那么我已經建立了連接。

ssh -i c:/[PATH]/[PEM-FILE].pem ec2-user@[HOST].compute.amazonaws.com

如果我嘗試不使用-i,則沒有連接。

$ ssh ec2-user@[HOST].compute.amazonaws.com
Permission denied (publickey).

以下是使用-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).

因此,有一種不使用-i選項通過SSH進行連接的方法嗎?

經過幾次嘗試,我在這里找到了一篇帶有一些說明的文章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將識別出該密鑰並使用它”

@Everton Menonca'a表示贊賞。 實際上,它挽救了我的一天。 為了更多細節,我將提及我的案例:

  • 將私有密鑰(由EC2生成)加載到PuTTYgen中,然后從中導出OpenSSH密鑰。
  • 將導出的文件放在所有密鑰的主目錄中。 就我而言(windows)是C:\\Users\\USERNAME\\.ssh
  • 由於我要使用Bash連接到多個遙控器,因此我通過添加額外的條目來更新了config文件(在同一目錄下),如下所示:

     Host bitbucket.org IdentityFile ~/.ssh/id_rsa1 Host ec2-00-00-000-00.compute-1.amazonaws.com IdentityFile ~/.ssh/id_rsa2 

就這樣

暫無
暫無

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

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