简体   繁体   English

使用SSH与Ansible连接到Vagrant guest虚拟机时出错

[英]Error connecting with Ansible to Vagrant guest using SSH

I'm using Ubuntu to run Vagrant and I'm receiving an error every time I try to connect (reformatted for readability): 我正在使用Ubuntu运行Vagrant,每次尝试连接时都会收到错误消息(出于可读性考虑,对其进行了重新格式化):

<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE ping
<127.0.0.1> EXEC ssh -C -tt -vvv -o ControlMaster = auto -o ControlPersist = 60s
  -o ForwardAgent = yes -o ControlPath="/home/naruto/.ansible/cp/ansible-ssh-%h-%p-%r"
  -o StrictHostKeyChecking=no -o Port=2202
  -o IdentityFile="/home/naruto/test/.vagrant/machines/default/virtualbox/private_key"
  -o KbdInteractiveAuthentication=no
  -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey
  -o PasswordAuthentication=no -o User=vagrant
  -o ConnectTimeout=10 127.0.0.1 /bin/sh -c
    'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1452294114.84-103845443589966
    && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1452294114.84-103845443589966
    && echo $HOME/.ansible/tmp/ansible-tmp-1452294114.84-103845443589966'
testserver | FAILED => SSH Error: command-line line 0: missing argument.
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug
  output to help diagnose the issue.

This is the information in the vagrant ssh-config: 这是无所事事的ssh-config中的信息:

Host default
HostName 127.0.0.1
User vagrant
Port 2202
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/naruto/test/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL

And this is the hosts file for Ansible: 这是Ansible的主机文件:

[example]
testserver
ansible_ssh_host=127.0.0.1
ansible_ssh_port=2202
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=/home/naruto/test/.vagrant/machines/default/virtualbox/private_key

Any idea what this problem is or how can I troubleshoot this further? 知道这是什么问题,或者如何进一步解决该问题? Thanks. 谢谢。

 ssh -C -tt -vvv -o ControlMaster = auto -o ControlPersist = 60s -o ForwardAgent = yes 

This part is wrong. 这部分是错误的。 You can't put spaces between option and argument. 您不能在选项和参数之间放置空格。 You need to use it the same way as the other options below: 您需要使用与以下其他选项相同的方法:

ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s
  -o ForwardAgent=yes 

Though I have no idea where does it come from. 虽然我不知道它从哪里来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM