SSH ProxyCommand not working with ansible_ssh_common_args

ansiblessh

I'm using a jump box (server A) to access server B.

As per the ansible docs here, I have the following:

ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q ec2-user@A.A.A.A"'

Server B is, let's say: 10.0.2.54

I run:

ansible-playbook staging.yml -i staging_hosts --private-key=~/.ssh/mykeys.pem -vvvv

And the result is:

fatal: [10.0.2.54]: UNREACHABLE! => {"changed": false, "msg": "All    items completed", "results":
[{"item": ["openssl"], "msg": "ERROR! SSH encountered an unknown error.
The output was:\nOpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011\ndebug1:
Reading configuration data /etc/ssh_config\r\ndebug1: /etc/ssh_config  line 20: Applying options for *\r\ndebug2:
ssh_connect: needpriv 0\r\ndebug1:
Executing proxy command: exec ssh -W 10.0.2.54:22 -q ec2- user@A.A.A.A\r\ndebug3:
timeout: 10000 ms remain after connect\r\ndebug3: Incorrect RSA1   identifier\r\ndebug3:
Could not load \"/Users/me/.ssh/mykeys.pem\" as a RSA1 public key\r\ndebug1:
permanently_drop_suid: 501\r\ndebug1: identity file    /Users/me/.ssh/mykeys.pem type -1\r\ndebug1:
identity file /Users/me/.ssh/mykeys.pem-cert type -1\r\ndebug1:
Enabling compatibility mode for protocol 2.0\r\ndebug1:
Local version string SSH-2.0-  OpenSSH_6.2\r\nssh_exchange_identification:
Connection closed by remote host\r\n", "unreachable": true}]}

Best Answer

May it be that you need to define an SSH key for the jump server A? If that's the case, try to change the SSH args line to:

ansible_ssh_common_args: '-o ProxyCommand="ssh -W %h:%p -q -i <path_to_jumphost_keyfile> ec2-user@A.A.A.A"'