Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux system misoperation execution: chmod-R 777 / later repair method

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Accidental misoperation: chmod-R 777! It's over? Modified all file permissions of the Linux system, for reference only!

Linux system has no operation to execute: repair method after chmod-R 777:

1) do not exit the current login window after execution!

If you cannot log in to ssh, it should have something to do with the files passwd, group, shadow and ssh. Open another linux to view the permissions and modify them to the corresponding permissions on the wrong machine:

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

Service sshd restart restarts the sshd service

Test reconnecting to ssh to see if the connection can be successful until the connection is successful

2)

Find a linux system (as clean as possible), export the permissions of the system, and then import it into this machine.

Execute on a good machine

Cd /

Getfacl-R / > linux.chmod.txt

Then upload it to the machine to be repaired by ftp or rz command

Execute:

Cd /

Setfacl-restore=linux.chmod.txt

Check directly: whether the permission is normal! Abnormal execution again, check again to see if it is normal!

If it is not executed in the / directory and the result does not take effect, you will probably need reboot! All recommended export and import operations under the root / directory

If it is not normal, you can do the following before trying reboot,reboot again:

Mkdir-p / root/sh

Cd / root/sh/

Vi sshtmp.sh

#-start-

Sleep 300

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 upright s `which su`

Chmod 755`which passwd`

Chmod Ubuns `which passwd`

Service sshd restart

#-end-

Put it on and start it up

Echo'/ root/sh/sshtmp.sh &'> > / etc/rc.local

And then reboot.

If you can log in to the system normally after reboot, you can first kill the process of sshtmp.sh and remove the script in / etc/rc.local. Then check to see if the permissions are normal.

Reference material for this article: http://blog.sina.com.cn/s/blog_5937eedc0101h719.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report