禁止root直接登陆linux系统

Posted 夕颜@伤雨痕

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁止root直接登陆linux系统相关的知识,希望对你有一定的参考价值。

直接修改文件

# vim /etc/ssh/sshd_config

SyslogFacility AUTHPRIV
PermitRootLogin no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile	.ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
UsePAM yes
X11Forwarding yes
Subsystem	sftp	/usr/libexec/openssh/sftp-server
/etc/init.d/sshd restart

  如何免密码切换到root呢?

vim   /etc/sudoers

【普通账号】 ALL=(ALL) NOPASSWD: ALL

保存之后,回到普通用户直接输入sudo -s即可免密切换到root账号



以上是关于禁止root直接登陆linux系统的主要内容,如果未能解决你的问题,请参考以下文章