编程知识 cdmana.com

Recovery after Linux misoperation 777

The first stage , Repair SSH( If ssh Not disconnected , perhaps vnc If you can log in, you can repair the permissions directly without mounting )

After misoperation , The system can't log in , At this time, you need to hang up the disk to check the problem , After hanging the disk , You can do the following to fix ssh And the problem of system login

Hang up the tray first , then chroot once , Or enter the corresponding directory

cd /etc
     chmod 644 passwd group shadow 
     chmod 400 gshadow 
     cd ssh
     chmod  600  moduli  ssh_host_dsa_key ssh_host_key ssh_host_rsa_key 
     chmod  644 ssh_config ssh_host_dsa_key.pub ssh_host_key.pub ssh_host_rsa_key.pub
     chmod  640 sshd_config

    chmod 600 /etc/sscuretty

    chmod 711 /var/empty/sshd

     chmod u+s `which su`( This step is generally not performed , Available in ubuntu In the process of repairing )

     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.

After repair, uninstall and restart to use ssh And log in to the management terminal

The second stage , Restore the system permissions before misoperation

You need to find one that's OK first , Machines with little difference in kernel versions , Get permissions for this machine ( If the business is different , The file permissions applicable to the corresponding business will not be overwritten , You need to set it manually )

perform

getfacl -R / > ./linux.chmod.bak

     
  • 1.

Get the right permissions ,copy To the problematic system

perform

cd /
setfacl --restore=/root/linux.chmod.bak 

     
  • 1.
  • 2.

Then restart the machine to replace the original permissions

At present, it's only in centos 6.5 I tested it , Verification passed .

  Link to the original text

版权声明
本文为[Leoheng08]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/08/20210809183557254I.html

Scroll to Top