我尝试使用以下命令在端口22上以Root用户身份连接到我的Linux centOS服务器:
ssh -p 22 root@ip
但是连接返回此错误:
root@ip: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
我应该怎么办?
首先,你必须使用以下命令更改服务器计算机上的权限:
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服务。