[英]SSH connection denied by EC2 instance
我正在嘗試將 SSH 放入我在 EC2 上的實例中,但獲得的權限被拒絕。 端口 22 在安全組中打開。 我將 400 設置為文件的權限,該文件在這種情況下應該有效,因為我只需要讀取。 我可以設置 600 但在這種情況下它是不必要的。
我應該去哪里看看? 我怎樣才能解決這個問題?
ec2-user@35.178.89.23: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
詳細標志顯示:
debug1: Host '3.8.3.177' is known and matches the ECDSA host key.
debug1: Found key in /home/mark/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:rSHi+GMCUIvsF4HA0Kv5C0++sLGGiquVQ/z/OXQBPEU mark.alexa@mail.com
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /home/mark/.ssh/ecs.pem
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: No more authentication methods to try.
ec2-user@3.8.3.177: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
AWS 有一個很好的故障排除指南。
一些常見的原因是:
請確保您使用正確的私鑰 ( ssh -i key.pem ec2-user@hostname
) 進行連接,並使用-v
選項從 ssh 獲取詳細日志記錄。 這可以幫助您確定請求是否實際發送到 EC2 實例(因此它不是連接問題)或沒有(因此它是連接問題)。
根據您分享的症狀,我想說/home/mark/.ssh/ecs.pem
不是與您在啟動 EC2 時提供的密鑰對關聯的私鑰,或者您在沒有密鑰對的情況下啟動了 EC2。
您應該能夠使用openssl rsa -in /home/mark/.ssh/ecs.pem -pubout -outform DER | openssl md5 -c
計算 PEM 文件的指紋。 openssl rsa -in /home/mark/.ssh/ecs.pem -pubout -outform DER | openssl md5 -c
並將其與 EC2 密鑰對控制台中顯示的指紋進行比較。 如果它們不匹配,則說明您使用了錯誤的私鑰。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.