1

A while ago i was able to connect to my server using SSH and suddenly it stopped working.

I am trying command: ssh -i "mykey.pem" ubuntu@server-ip and Ec2 throws back an exception

Permission denied (publickey). When I tried to attempt the connection using the SFTP it thrown the error

Error:          Server sent disconnect message
Error:          type 2 (protocol error):
Error:          "Too many authentication failures"
Error:          Could not connect to server

I then used to fire the command in -v mode and following is the output. Can you guys please help me solve this issue. I totally, burning up heat on this.

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to x.x.x.x [x.x.x.x] port 22.
debug1: Connection established.
debug1: identity file mykey.pem type -1
debug1: identity file mykeypem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 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 x.x.x.x:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:6NiTFBw2gv2t9lxZJlAxMbNJ7Ih2WcEmp2S3McfuFe0
debug1: Host 'x.x.x.x' is known and matches the ECDSA host key.
debug1: Found key in /Users/myuser/.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: Will attempt key: mykey.pem  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: mykey.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

1 Answer 1

1

The root cause for the problem that i was facing was one of my team members had changed the permissions of /home/user directory to 777.

This spoils everything.

The right permissions are:

/home/user 600
/home/user/.ssh 700
/home/user/.ssh/authorised_keys 0600

Hope this will be helpful to others.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .