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. href="https://serverfault.com/questions/364677/why-is-chmod-r-777-destructive">Why is
"chmod -R 777 /" destructive?
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
and
{packagename}rpm --setugids
{packagename}
To fix you
all system just rum them in loop href="http://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html"
rel="nofollow noreferrer">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
It will
restart sshd
failsystemctl status sshd
It
will show you the file with wrong permissions- Fix the
file permission usingchmod 0700 -R /root/.ssh
OR
chmod 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