SSH ProxyCommand不能使用ansible_ssh_common_args

我正在使用跳转框(服务器A)访问服务器B.

根据这里的能力文件,我有以下几点:

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

服务器B是,让我们说:10.0.2.54

我运行:

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

结果是:

 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@AAAA\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}]} 

可能是你需要为跳转服务器A定义一个SSH密钥? 如果是这种情况,请尝试将SSH参数更改为:

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