Ansible:如何解决“sudo:需要密码"错误? [英] Ansible: how to solve "sudo: a password is required" error?

查看:31
本文介绍了Ansible:如何解决“sudo:需要密码"错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 9 台服务器,我正在尝试使用 ansible 安装一个软件包,我可以使用密码通过 ssh 连接到其中的 5 台服务器,而其他 4 台在 ssh 连接时不会询问任何密码.

I have 9 servers and i am trying to install a package using ansible, i am able to ssh into 5 of the servers using a password and other 4 does not ask any password while ssh'ng into them.

但是我已经将 id_rsa.pub 密钥复制到了所有 9 个服务器.

However i have copied id_rsa.pub key to all the 9 servers.

现在 ansible 脚本在 5 个服务器上运行良好,但剩下 4 个我收到以下错误消息.

Now the ansible script is working fine for 5 server but w remaining 4 i am getting the following error message.

致命:[xxx0?]:失败!=> {"changed": false, "failed": true, "module_stderr": "Connection to xxx0? closed.\r\n", "module_stdout": "sudo: 需要密码\r\n", "msg": "模块失败", "rc": 1}

fatal: [xxx0?]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Connection to xxx0? closed.\r\n", "module_stdout": "sudo: a password is required\r\n", "msg": "MODULE FAILURE", "rc": 1}

我的 Ansible.cfg

My Ansible.cfg

[defaults]
filter_plugins =./filter_plugins
roles_path = ./roles
sudo_user = root
host_key_checking = False
retry_files_enabled = False
password = ~/password.txt
timeout = 25

[ssh_connection]
ssh_args = -F ~/.ssh/config -o ControlMaster=no -o ControlPersist=30m
control_path = ~/.ssh/ansible-%%r@%%h:%%p

~/.ssh/config

~/.ssh/config

Host xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? .xyz.com
  User yyy
  Port 22

ansible 版本 = ansible 2.3.1.0

ansible version = ansible 2.3.1.0

我该如何解决这个错误?

How can i solve this error ?

推荐答案

出现错误:

sudo:需要密码

这并不意味着您无法连接到目标计算机,而是意味着您需要提供密码才能运行具有提升权限的命令(或者您无法完全运行具有提升权限的命令).

It doesn't mean you can't connect to the target machine it means you need to provide a password to run a command with elevated permissions (or that you can't run a command with elevated permissions altogether).

相反,这意味着正在建立连接没有问题.

On the contrary, it means the connection is being established with no problems.

在受影响的机器上修复您的 sudoers 配置.

Fix your sudoers configuration on the affected machines.

这篇关于Ansible:如何解决“sudo:需要密码"错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆