摘要:我正在尝试在 Ubuntu 14.x 服务器上安装 Ansible。
我正在尝试按照以下步骤操作: http://docs.ansible.com/intro_installation.html
当我以 root 身份发出此命令时,遇到了问题:
# ansible all -m ping --ask-pass -vvvv
(我添加了 -vvvv 以获取详细的调试信息。)
以下是我所看到的:
SSH password:
<127.0.0.1> ESTABLISH CONNECTION FOR USER: root
<127.0.0.1> REMOTE_MODULE ping
<127.0.0.1> EXEC ['sshpass', '-d6', 'ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'GSSAPIAuthentication=no', '-o', 'PubkeyAuthentication=no', '-o', 'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1430936987.71-278505449931727 && echo $HOME/.ansible/tmp/ansible-tmp-1430936987.71-278505449931727'"]
127.0.0.1 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/root/.ansible/cp/ansible-ssh-127.0.0.1-22-root" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug3: timeout: 9996 ms remain after connect
debug1: permanently_set_uid: 0/0
debug3: Incorrect RSA1 identifier
debug3: Could not load "/root/.ssh/id_rsa" as a RSA1 public key
我做错了什么?我尝试创建 ssh 密钥。但没用。
答案1
正如 grag42 指出的那样,不要以 root 身份运行 ansible。
确保您可以通过 ssh 连接到您想要使用 ansible 管理的任何主机,而无需输入密码或密码,即使用 ssh 密钥和密钥代理(或没有密码的密钥;不推荐)。
确保您用来运行 ansible 的用户sudo
在目标主机上拥有完全权限,而无需输入密码。