After changing permissions to home/ec2-user of the main volume I can no longer SSH in even after changing permissions

MistyD asked:

AS the title mentions. I was dumb enough to change the permissions of home/ec2-user recursively to 777 after which I could not log in. I then detached the volume and then attached it to another instance and changed the permission to 700 recursively of that folder. Now when I try to connect to it using the following command I get the error

     ssh -v -i  ~/Amazon-fooDev/fooDev.pem [email protected]
OpenSSH_7.8p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/admin/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to port 22.
debug1: Connection established.
debug1: identity file /Users/admin/Amazon-fooDev/fooDev.pem type -1
debug1: identity file /Users/admin/Amazon-fooDev/fooDev.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.8
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: 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 as 'ec2-user'
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: chacha20[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:XJWnn7TLa5feJVY7kAOUJQGmWm8J3UNQ/MM+uQZa+Sk
debug1: Host '' is known and matches the ECDSA host key.
debug1: Found key in /Users/admin/.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
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/admin/Amazon-fooDev/fooDev.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

Any suggestions on what I could do to fix this problem. I wasted an entire day trying to connect to that instance and get back to the state it was originally in. Any suggestions would be appreciated. Is 700 permission for home/ec2-user correct ? or should i change it to something else ? Do u think I might be looking in the wrong direction ?

My answer:

First, fix the syntax error. You say you used:

ssh -iv ~/Amazon-Permission/FooDev.pem [email protected]

This tries to load an ssh private key named v, which is not what you want. You want the ssh private key named ~/Amazon-Permission/FooDev.pem. Remove the stray v that got in there somehow.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.