rogerscuall
rogerscuall

Reputation: 5

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):

<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:

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:

[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.

Upvotes: 0

Views: 1280

Answers (1)

Jakuje
Jakuje

Reputation: 25956

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.

Upvotes: 1

Related Questions