Linux系统 开启SSH root账号登录 解决ssh登陆时提示 Please login as the user “centos“ rather than the user “root“.

最近给openstack创建的虚机(系统CentOS 7 )尝试使用ssh登录时候提示要我用普通账号centos进行登录,无法使用root账号登录
提示信息:

Please login as the user "centos" rather than the user "root".

在这里插入图片描述
下面的配置步骤参考了https://cyhour.com/1539/ 这篇文章,对虚机系统进行配置

使用普通账号登录虚机

ssh [email protected]

切换到root账号

sudo -i

配置root密码

passwd

打开ssh配置文件

vi /etc/ssh/sshd_config

修改或添加下面配置

PermitRootLogin yes
PubkeyAuthentication yes

Linux系统 开启SSH root账号登录 解决ssh登陆时提示 Please login as the user “centos“ rather than the user “root“._第1张图片

编辑认证文件authorized_keys

vi /root/.ssh/authorized_keys 

在这里插入图片描述

删除

no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"centos\" rather than the user \"root\".';echo;sleep 10"

重启ssh服务

systemctl restart sshd

测试使用root账号登录

ssh [email protected]

-
可以看到登录成功

你可能感兴趣的:(Linux,linux)