Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Im gonna need some help restoring my ssh settings as i screwed everything up by calling this command:

chown -R user /

At the moment im not able to access the site through ssh/ftp since the ownership of all the files have been changed. I dont want to reset every ownership but if i could get ssh working i would be able to create a backup of my files and then get a clean install of ubuntu on my server.

Here is the error that i get when im trying to restart ssh:

/var/run/sshd must be owned by root and not group or world-writable.

Im running ubuntu 10.04 LTS. Any help is very much appreciated.

P.S. I am able to run ssh commands on a browser based AJAX console that my hosting company (linode) provides.


share|improve this question

closed as too localized by Luis Alvarado Mar 14 '13 at 17:02

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

This is why you never login as root! If you were your own user, you wouldn't have been able to do this! – jathanism Aug 24 '10 at 18:56
Well... maybe, but chown always has to be run as root (at least on my system. I don't know if this is configurable). So even if you're not logged in as root, you'd still be using sudo or something whenever you run a chown command. – David Z Aug 25 '10 at 1:09

First to stop the error message change the owner of /var/run/sshd back to to root.

There might be more errors afterwoods, which probably mean you need to change other files too.

share|improve this answer

Wow. You might be able to restore your permissions. It's a long shot but possibly worth considering if you've customised the install a lot.

Here's something I just concocted. This should (not tested) set every file in the root group to be owned by root.

sudo find / -group root -exec chown root {} \;
share|improve this answer
it is probably safer to restore from the backup. While this probably get close to fixing it, I am not sure if anybody has ever checked it. And furthermore, it only fixes the root group, not any other users. – txwikinger Aug 24 '10 at 19:51
From what I gather, there is no backup to restore from. He wants to make a backup once SSH'd in. For other files he could make a quick local install with a similar config do a funny find that prints the full path and owner, port that list to the broken server and then restore owners from that file. None of this is as "good" as a clean install or a real backup but time is often a factor. – Oli Aug 24 '10 at 20:26

Well, best/easiest thing would be to restore your backup. You do backups, right?

Besides, this blog post describes some approaches to reset permissions this via apt-get/dpkg. Before trying this, you should do something like Oli posted (chown everything or a subset back to root again).

If you don't do backups, now is the time to start! ;)

share|improve this answer
Backups are good, but a lot of backup systems don't keep the owners. – ℝaphink Aug 24 '10 at 9:29
@raphink: name one! Every serious backup system is able to backup/restore owner information (besides other file attributes). – maxschlepzig Aug 24 '10 at 10:45