我想通过ssh连接ansible到EC2。我在本地机器(Ubuntu)上创建了一个密钥对,并使用ssh-copy将其复制到我的EC2实例中。复制是成功的,但是当我想连接到实例时,我会得到下面的错误:
Failed to connect to the host via ssh: root@34.xxx.0x.xxx: Permission denied (publickey)当我检查远程机器上的auth.log文件时,我看到以下日志:
invalid user usuario from 187.xx.xx.xx port 47988这是我的etc/ansible/host文件
[host1]
github ansible_host=13.xxx.xxx.xx ansible_user=root任何帮助都将不胜感激。谢谢
发布于 2020-02-27 07:29:32
通常,我们应该使用域凭据(而不是基于密钥的身份验证)从控制节点到远程服务器运行剧本。
但在您的示例中,您正在尝试使用根用户和密钥进行身份验证。因此,请按照以下步骤操作:
“/home/ansible/.ssh/authorized_keys”中,您希望通过不可失控制节点来管理该服务器。ssh -i /path/to/private-key ansible@<remoteserverip>希望检查SSH,这会有所帮助。关于不可接受的配置,在/etc/ansible/ansible.cfg中将有一个参数提到私有。private_key_file = /path/to/private-key
发布于 2020-02-27 12:01:45
我需要在远程服务器上的PasswordAuthentication文件中设置sshd_config yes,这解决了这个问题。
https://askubuntu.com/questions/1213313
复制相似问题