When I try to ssh into my ec2 host, I get a permission refused error. I tried the previously suggested method of chmod 600 “My.pem,” but it didn’t work. My debug information is as follows:
debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 220.127.116.11 [18.104.22.168] port 22. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file My.pem type -1 debug1: key_load_public: No such file or directory debug1: identity file My.pem-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.9 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to 22.214.171.124:22 as 'root' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client email@example.com <implicit> none debug1: kex: client->server firstname.lastname@example.org <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:tfjxcE5kePSv1cJK7SWBp/56kgm2DQkyPLSLZ4d73Io debug1: Host '126.96.36.199' is known and matches the ECDSA host key. debug1: Found key in /Users/tan/.ssh/known_hosts:24 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent 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: My.pem debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
Asked by lawzlo
In my Centos computer, I was able to address this problem by running the following command:
ssh -i <Your.pem> ec2-user@<YourServerIP>
It was regarding userName, which in my case was ec2-user.
Referenced From: AMAZONTroubleshooting
Answered by Harneet Singh
Connecting with the user centos instead than ec2-user solved the problem.
Answered by liorko
Each Linux instance, I noticed, starts with the default Linux system user account. Depending on your instance, this may differ from ec2-user. You log in with the command DefaultUserName, where DefaultUserName is a username from the quote below.
ssh -i <Your.pem> <DefaultUserName>@<YourPublicServerIP>
Answered by oshell
Default usernames for Amazon EC2 instances may be found here: https://alestic.com/2014/01/ec2-ssh-username/
However, if you want to know what your instance’s username is, click the Connect button to see the default username.
Run this command once you’ve found the username to make sure your key isn’t visible to the public.
chmod 400 <private-key-file.pem>
Then, using its Public DNS or IP, connect to your instance:
ssh -i <private-key-file.pem> ec2-user@<public ip>
Answered by Sahar Pk
Add the user to the /etc/sshd special users file.
Answered by 2 revs, 2 users 67%
Post is based on https://stackoverflow.com/questions/33991816/ec2-ssh-permission-denied-publickey-gssapi-keyex-gssapi-with-mic