Server Fault is a question and answer site for system and network administrators. 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

I'm running RHEL 6.0, and I accidentally moved the /bin, /boot, /cgroup, console.txt, /data, /dev, /etc to another folder. I think I managed to move these folders back, but now I'm having trouble connecting to the server using SSH, but am able to access the server via VNC.

When I tried to connect to the server using a terminal from another server, I get the error

ssh_exchange_identification: Connection closed by remote host

I'm currently still connected via SSH to the server (haven't closed the window yet), and am still able to access it normally. But if I try to open a new SSH terminal from my current session, I see

/bin/bash: Permission denied

If I try to open a new SSH File Transfer window from my current session, I get the error

File transfer server could not be started or it exited unexpectedly. 
Exit value 0 was returned. Most likely the sftp-server is not in the path of the user on the server-side

I checked and I have

Subsystem  sftp  /usr/libexec/openssh/sftp-server

which is the same path as the output of

locate sftp-server

Also, when I tried to restart sshd, I get the error

Couldn't open /dev/null: Permission denied

But my /dev/null has the permissions


for root,root.

How can I resolve this?

ETA: Thanks for all your help! I was able to start ssh by running the application directly


Even though the status of the openssh-daemon is still "stopped".

share|improve this question
Run rpm -Va to check the files that are not in place and restore them, set the correct permission, run restorecon if you are using selinux then test again. – topdog Apr 12 '12 at 12:23

Unfortunately, your best course of action here is to reinstall your OS. It may theoretically be possible to fix this specific permissions error, but then you still have hundreds of other files and folders in an unknown state, any of which could cause malfunctions in the future.

This is your only path back to a stable, reliable system.

share|improve this answer

As others have remarked the only safe way to restore the system fully is to restore from backup.

If you are unable to do so you could check the RPM DB (rpm -Va) to see what files are still missing and/or have the wrong permissions.

See e.g. this post and this on how to restore permissions using rpm.

Good luck.

share|improve this answer

As things are clearly not working as they should be and you aren't really certain that you have fully undone any damage caused by moving things around I suggest that the only sensible course of action at this point is to restore the system from backup. Anything else is liable to leave your system in an unpredictable state.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.