Warm tip: This article is reproduced from serverfault.com, please click

其他-通过SSH错误连接到CentOS 7.9权限被拒绝

(其他 - Connecting to CentOS 7.9 with SSH error Permission Denied)

发布于 2020-11-29 09:31:51

我尝试使用以下命令在端口22上以Root用户身份连接到我的Linux centOS服务器:

ssh -p 22 root@ip

但是连接返回此错误:

root@ip: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

我应该怎么办?

Questioner
sajjad serajzadeh
Viewed
11
sajjad serajzadeh 2020-11-29 17:31:51

首先,你必须使用以下命令更改服务器计算机上的权限:

chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys

然后在/ etc / ssh / sshd_config中对此进行编辑:

sudo sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config;

跑步:

systemctl stop sshd.service

并运行:

systemctl enable sshd.service

然后运行:

systemctl start sshd.service

之后:

systemctl status sshd.service

并检查输出。如果一切顺利,则从现在开始每次启动时都应具有ssh服务。