簡體   English   中英

權限被拒絕(公鑰、gssapi-keyex、gssapi-with-mic)-EC2 AWS

[英]Permission denied (publickey,gssapi-keyex,gssapi-with-mic) - EC2 AWS

我正在嘗試通過 Mac 上的終端連接到我的 EC2 實例。 我的密鑰存儲在 /downloads 文件夾中,我已經運行了以下命令:

chmod 600 mykey.pem

在運行以下命令之前:

ssh -t mykey.pem root@public-ip4-address

我也嘗試過其他用戶名 - “ec2-user”、“root”、“admin”等。但似乎沒有任何效果。

hostkeys_find_by_key_hostfile: hostkeys_foreach failed for /Users/abhisheksharma/.ssh/known_hosts: Not a directory
The authenticity of host 'xxxxxxxxxxxxxxxxx' can't be established.
ED25519 key fingerprint is SHA256:Uw1xxxxxxxxxxxxxxxxxxxxxSIb57A.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/Users/abhisheksharma/.ssh/known_hosts).
root@xxxxxxxxxxxxx: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

更多細節:

abhisheksharma@Abhisheks-MacBook-Air downloads % ssh -i storme.pem root@xxxxxxxxxxxxxxxx.compute.amazonaws.com -v
OpenSSH_8.6p1, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug1: Connecting to xxxxxxxxxxxxxxxx.compute.amazonaws.com port 22.
debug1: Connection established.
debug1: identity file storme.pem type -1
debug1: identity file storme.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: compat_banner: match: OpenSSH_7.4 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to xxxxxxxxxxxxxxxxcompute.amazonaws.com:22 as 'root'
debug1: load_hostkeys: fopen /Users/abhisheksharma/.ssh/known_hosts: Not a directory
debug1: load_hostkeys: fopen /Users/abhisheksharma/.ssh/known_hosts2: Not a directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacxxxxxx@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chaxxxxxxx@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-xxxxxxxx SHA256:Uw1ljnksxxxxxxxxxxxxxxxxSIb57A
debug1: load_hostkeys: fopen /Users/abhisheksharma/.ssh/known_hosts: Not a directory
debug1: load_hostkeys: fopen /Users/abhisheksharma/.ssh/known_hosts2: Not a directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
hostkeys_find_by_key_hostfile: hostkeys_foreach failed for /Users/abhisheksharma/.ssh/known_hosts: Not a directory
The authenticity of host 'ec2-xxxxxxxxxxxxxxxx.compute.amazonaws.com (xxxxxxxxxxxxxxxx)' can't be established.
ED25519 key fingerprint is SHA256:Uw1ljnkxxxxxxxxxxxxxxxxIb57A.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Failed to add the host to the list of known hosts (/Users/abhisheksharma/.ssh/known_hosts).
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: storme.pem  explicit
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: publickey
debug1: Trying private key: storme.pem
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: No more authentication methods to try.
root@ec2-xxxxxxxxxxxxxxxx.compute.amazonaws.com: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

像這樣使用

ssh -i Downloads/<pemfile>.pem ubuntu@<publicip>

如果創建的機器是 ubuntu

試試這個:

chmod 400 mykey.pem

代替

chmod 600 mykey.pem

而不是 root 嘗試添加 ec2-user

它對我有用!

暫無
暫無

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

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