限制root远程登录后root还是可以远程登录

限制root远程登录操作

1.首先执行备份:

#cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config_bak

2.确保系统存在除root之外的其他用户,防止设备配置完之后用户无法远程访问,若不存在其他用户,则使用如下命令添加用户

#useradd username
#passwd username

3.开启普通用户切换root用户,在/etc/sudoers文件里面添加一行:

username      ALL=(ALL)       ALL

4.配置禁止root用户直接远程登录系统:

编辑文件/etc/ssh/sshd_config修改PermitRootLogin值为no

PermitRootLogin no 

5.重启ssh服务
#systemctl restart sshd

6.正常情况限制root远程登录成功!但是重启服务后,发现root还是可以远程登录,查看配置文件

Match Group ftpuser

ChrootDirectory /data

ForceCommand internal-sftp

PermitRootLogin no

将PermitRootLogin no顺序调整至Match模块前重启服务后生效!

 

相关文章

背景:我已经有一个ssh公钥和私钥了,绑定的是公司的码云但是...
在服务器程序的部署运维过程中,我们经常需要将文件从一个服...
#!/bin/bash#创建一个以.sc结尾的文件,把要操作的主机按顺序...
打开终端安装openssh-server软件包:sudoaptupdatesudoaptins...
环境centos7.9,.NET5一、Jenkins搭建1)下载Jenkins的war包...
dropbear下载地址:https://matt.ucc.asn.au/dropbearelease...