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 /
and chmod 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 fail
systemctl status sshd
It will show you the file with wrong permissions
- Fix the file permission using
chmod 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