【问题标题】:Permission denied when running Ansible ad hoc command运行 Ansible ad hoc 命令时权限被拒绝
【发布时间】:2017-10-11 12:18:24
【问题描述】:

我正在尝试在 Ubuntu 14 LTS 服务器上通过 SSH 运行 Ansible ad hoc 命令:

ansible all -m ping -u myusername

但是我收到以下错误消息:

FAILED => SSH 错误:权限被拒绝(公钥、密码)

当我尝试运行带有询问密码标志的广告命令时,它可以工作:

ansible all -m ping -u myusername --ask-pass

absence.ugent.be | success >> {
"changed": false,
"ping": "pong"
}

有谁知道为什么在不询问我的密码的情况下该命令不起作用?我该如何解决这个问题?

更新:正如 neuhaus 建议的那样,我尝试从我的 ssh 密钥文件中删除密码短语:

ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]

但这并没有解决问题。奇怪的是我居然还能成功跑

ansible all -m ping -u myusername --ask-pass

使用我的旧密码,即使在创建新的 ssh 密钥之后也是如此。

感谢您的帮助,
安东尼

【问题讨论】:

标签: ssh ansible ubuntu-14.04


【解决方案1】:

您的 SSH 密钥受密码保护。通过添加--ask-pass,ansible 将要求输入此密码(不是您的登录密码)。

如果您希望此功能无需输入密码即可使用,remove the passphrase from your SSH key。

【讨论】:

  • 嗨,neuhaus,非常感谢。如何从我的 SSH 密钥中删除密码?
  • 点击我刚刚在我的答案中添加的链接。或者下一次,使用搜索引擎 - 它比在 stackoverflow 中输入评论更快!
  • 我用 ssh-keygen -p 删除了密码,但这并没有解决问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-31
  • 1970-01-01
  • 2015-06-18
  • 2021-11-02
  • 2020-02-03
相关资源
最近更新 更多