简体   繁体   English

权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)-EC2 AWS

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

I am trying to connect to my EC2 instance via the Terminal on Mac.我正在尝试通过 Mac 上的终端连接到我的 EC2 实例。 My key is stored in /downloads folder and I have already ran the following command:我的密钥存储在 /downloads 文件夹中,我已经运行了以下命令:

chmod 600 mykey.pem chmod 600 mykey.pem

before running the following:在运行以下命令之前:

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

I have tried other usernames also - "ec2-user", "root", "admin" etc. But nothing seems to work.我也尝试过其他用户名 - “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).

More Details:更多细节:

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).

Use like this像这样使用

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

if created machine is of ubuntu如果创建的机器是 ubuntu

Try this:试试这个:

chmod 400 mykey.pem

Instead of代替

chmod 600 mykey.pem

and instead of root try adding ec2-user而不是 root 尝试添加 ec2-user

It worked for me!它对我有用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 EC2 ssh 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic) - EC2 ssh Permission denied (publickey,gssapi-keyex,gssapi-with-mic) 通过 SSH 从 Windows 连接到 AWS Linux 实例时出现问题 [权限被拒绝; (公钥,gssapi-keyex,gssapi-with-mic)] - Problem connecting via SSH from Windows to AWS Linux Instance [Permission denied; (publickey,gssapi-keyex,gssapi-with-mic)] 用户@<ip address> :权限被拒绝(publickey,gssapi-keyex,gssapi-with-mic)</ip> - user@<ip address> : Permission denied (publickey,gssapi-keyex,gssapi-with-mic) Amazon EC2 SSH 服务器发送:(公钥、gssapi-keyex、gssapi-with-mic) - Amazon EC2 SSH server sent: ( publickey, gssapi-keyex,gssapi-with-mic) 谷歌云引擎。 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic) - Google Cloud Engine. Permission denied (publickey,gssapi-keyex,gssapi-with-mic) ssh:权限被拒绝(公钥,gssapi-with-mic) - ssh : Permission denied (publickey,gssapi-with-mic) 从 ec2 到 github 的权限被拒绝(公钥) - Permission denied (publickey) from ec2 to github 无法通过 FTP 删除 AWS EC2 上的文件,权限被拒绝 - Cannot delete files on AWS EC2 via FTP, permission denied 从 Bastion 到 Private ec2 的权限被拒绝 - Permission denied from Bastion to Private ec2 EC2 权限被拒绝(公钥) - EC2 permission denied(public key)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM