March 20, 2018

How to break a website

If you saw on my Twitter, I may have broken my website on Friday night. I lost file and SSH access to it. How did it happen?

This all started with me moving my main domain over to hyper.lol. I thought I could just change all configs to the new domain and it would work. Some things were broken obviously. So I thought the issue was with file and folder ownership. So I change the directory to the site and did this command:

sudo chown -R www-data:www-data /

To anyone that is stupid enough, don't run that command above. It WILL break your computer/VPS. That command destroys the file/folder perms making your install break. My thought process was that the / was relative to where I currently was. That was not the case. At that point, I was unable to login at all. The server couldn't accept my key.

I realized what I did after I typed the command. Luckily, I was still logged in via WinSCP. To fix it, I just went to my root directory and mass changed the ownership back to root. I had to leave it on overnight; however, that still didn't work.

I ended up contacting my hosting's support. After about 10 emails, we decided that these were the best steps to fix this:

  • Support would mount a recovery tool. From there, I could access the files.
  • Download everything I want.
  • Support would unmount the recovery tool.
  • I rebuild the server's OS.

That is what we did, and now everything is working once again.

I also did change my domain over to hyper.lol, since I had the chance to rebuild everything.

TLDR, idiot tries to change file and folder perms but messes up the location on the command. Contacts support to fix.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket