← All posts

#chown on root is scarier than #rm -rf /

chown

Well, here’s part two, following on from the first installment of stupidity! No, it wasn’t PHP that suffered this time, but another server I was rebuilding.

Apparently I need to replace my keyboard: this is the second time I’ve failed to type a dot… even though I’m pressing it! I’d have been better off running “rm -rf /”… :)

Down to business: I was in a hurry, and instead of

# chown adw0rd:wheel ./*

can you guess what I did? :)

This:

# chown adw0rd:wheel /*

Naturally, I didn’t notice anything and carried on working… then I needed to reboot the server.
And darkness fell… :)

The realization

After the reboot, I log into the server as adw0rd, run “su”, and it tells me

su: not running setuid

I immediately Googled it, rushed over to /usr/bin/, and checked what was going on with su:

# ll su

I look, and the owner is adw0rd. What kind of joke is this, I wonder! O_o
I started poking around the server… and the owner everywhere was adw0rd. Then it hit me! I’d forgotten the damn dot!

How I fixed the problems

Well, since I now owned everything, I went to edit the sshd config to allow root access…

# vi /etc/ssh/sshd_config

Found the line

#PermitRootLogin no

and replaced it with

PermitRootLogin yes

I can’t reboot the server or restart sshd as adw0rd, and su won’t let me in either… so in the end I log into the hosting provider’s control panel and hit remote reboot.

After the reboot, I was able to log into the server as root. Now I’m changing ownership of all the files on the server to root, and gradually comparing permissions with another server and setting them to match.

Well, that’s about it. Everything works now :)

Comments are closed. Read the original discussion in Russian →