使用密钥进行 SSH 登录无法正常工作

使用密钥进行 SSH 登录无法正常工作

我有一个系统,想通过 ssh-keys 进行访问。

我创建了一个名为的用户,并创建了一个名为monitor的文件,并插入了2个公钥:authorized_keys/home/monitor/.ssh/

公钥 #1 来自同一主机,因为我想使用 apt-dater;apt-dater 尝试使用 ssh-key 连接到本地主机 (monitor@localhost)。这不起作用(要求输入密码)

公钥#2来自远程主机;用户“监控”应该连接到该主机来检查负载和其他内容。

两个公钥都不起作用;我无法从同一主机(ssh monitor@localhost或从另一台服务器)进行连接。ssh [email protected]

Error: debug1: Roaming not allowed by server

我可以在这里做什么?

答案1

该消息Error: debug1: Roaming not allowed by server仅仅是一个调试消息,仅此而已。


请按照以下步骤通过公钥进行身份验证:

在您的服务器上启用密码验证。打开 ssh-server 配置

 sudo nano /etc/ssh/sshd_config

并启用密码验证

PasswordAuthentication yes

重新加载配置

sudo service ssh reload

在您的客户端上

通过复制你的公钥ssh-copy-id

ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22 user@server 

或者作为替代方案

cat id_rsa.pub | ssh server cat >> ~/.ssh/authorized_keys 

在您的服务器上

sudo nano /etc/ssh/sshd_config

并禁用密码验证

PasswordAuthentication no

重新加载配置

sudo service ssh reload

相关内容