1

I'm working with an Amazon EC2 instance and at some point, I wanted to chown a directory recursively, and it looks like I applied the command to the whole file system. As a result, it is possible that most files now have ubuntu:www-data ownership.

I didn't know how to revert that, and I realized this might be a problem only after I logged out of the instance. Now, when I try to ssh to my instance, I get the following error:

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to www.myserver.com [Server IP address] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file AWS.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file AWS.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
ssh_exchange_identification: read: Connection reset by peer

I don't have any other access to the server than SSH. Is there something I can do to access my server?

Note: this is not a duplicate of Accidental chown under / as root since my issue is not about reverting the chown but about logging back into the server.

Arnaud
  • 111
  • You should start by sshing with the -v flag and display the results – ryekayo May 23 '16 at 18:45
  • @ryekayo Yep, I just added it in my question – Arnaud May 23 '16 at 18:49
  • Hmmm ok, this is a long shot but is there a way to SSH in as the user ubuntu? – ryekayo May 23 '16 at 18:53
  • @ryekayo This is what I always do (ssh -i AWS.pem ubuntu@www.myserver.com) – Arnaud May 23 '16 at 18:54
  • Would logging in with user www-data work? – figgyc May 23 '16 at 18:57
  • 6
    Create another AWS vm, mount the original vm's disk under /mnt, and then choose to either fix permissions or migrate the data to the new vm. – steve May 23 '16 at 18:57
  • @figgycity50 same result using ubuntu, www-data or root – Arnaud May 23 '16 at 18:58
  • @steve sounds like a good backup solution, thanks! at least I'm no longer freaking out about losing my data :) – Arnaud May 23 '16 at 18:59
  • @figgycity50, the www-data is the name of the group, not the user... – ryekayo May 23 '16 at 19:07
  • Your problem is, that your SSH configuration files, especially keyfiles don't belong to the "correct" user anymore. SSH is a bit allergic to that. If you're lucky, this http://unix.stackexchange.com/a/15141/19575 can help you, if you can log in using a password, that is. – Bananguin May 24 '16 at 05:58

0 Answers0