本文中介绍如何从意外运行# chmod -R 777 /命令,在Centos8操作系统上恢复默认权限。
本文中我们将故意在一个测试服务器上运行chmod 777命令,并尝试通过运行两个命令进行恢复。就是如下两条命令:
# rpm --setugids -a
# rpm --setperms -a
当再测试机上面执行下面命令之后,所有文件权限都会变成777。
[root@localhost ~]# chmod -R 777 /
列出根目录下面的内容:
[root@localhost ~]# ls -al /
下面是SSH相关的重要文件,需要有正确的权限和所有权。但是,由于运行chmod 777,以下所有文件都具有错误的权限。
[root@localhost ~]# ll /etc/ssh/
total 588
-rwxrwxrwx. 1 root root 563386 May 11 2019 moduli
-rwxrwxrwx. 1 root root 1727 May 11 2019 ssh_config
drwxrwxrwx. 2 root root 28 Dec 29 2019 ssh_config.d
-rwxrwxrwx. 1 root root 4444 May 11 2019 sshd_config
-rwxrwxrwx. 1 root ssh_keys 480 Dec 29 2019 ssh_host_ecdsa_key
-rwxrwxrwx. 1 root root 162 Dec 29 2019 ssh_host_ecdsa_key.pub
-rwxrwxrwx. 1 root ssh_keys 387 Dec 29 2019 ssh_host_ed25519_key
-rwxrwxrwx. 1 root root 82 Dec 29 2019 ssh_host_ed25519_key.pub
-rwxrwxrwx. 1 root ssh_keys 1799 Dec 29 2019 ssh_host_rsa_key
-rwxrwxrwx. 1 root root 382 Dec 29 2019 ssh_host_rsa_key.pub
带有chmod 777权限的SSH
下面尝试通过SSH远程登录服务器。由于主机密钥文件权限都变成了777了,所以登录会被拒绝。
下面再终端中ssh登录本机出现下面问题:
下面使用Xshell登录服务器,同样不能登录成功:
[C:\~]$ ssh root@192.168.43.131
Connecting to 192.168.43.131:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(192.168.43.131:22) at 10:28:06.
Type `help' to learn how to use Xshell prompt.
大型站长资讯类网站! https://www.0817zz.com