I managed to messed up server permissions on entire server
chown root:root -R /
chmod 777 -R /
How to fix it?
I can't login as root using terminal on that machine it show error "Invalid password" and SSH shows error "connection reset by remote server"
Note:
I try to reinstall CentOS 7 using USB. but got stuck during Select disk stage as it will not let me select / without formating it.
This question explains what my commands did. Why is "chmod -R 777 /" destructive?
Answer
I managed to Solve it, here are the steps i followed.
To fix the issue of root login using terminal.
- boot using bootable USB/CD
- select recover and mound disk
- go to mounted folder and run
chown root -R /
andchmod 755 -R /
chmod 0700 -R /root/.ssh
- reboot normally
- Ignore SElinux contexts warnings and let it re-store contexts
After this you will be able to login to machine using root
To fix file permission and owners info use these commands rpm --setperms {packagename}
and rpm --setugids {packagename}
To fix you all system just rum them in loop more details here
for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done
It will fix permissions for most of packages.
If you can't login using SSH follow these steps
systemctl restart sshd
It will failsystemctl status sshd
It will show you the file with wrong permissions- Fix the file permission using
chmod 0700 -R /root/.ssh
ORchmod 0700 your_file_path
- repeat this process until SSH service start successfully
Using these steps I managed to restore all essential services on my server.
Finally to restore default permissions for vhosts created using Plesk.
I use this command as described on plesk website
# /usr/local/psa/bin/repair --restore-vhosts-permissions
Comments
Post a Comment