1
votes

I am trying to ping remote host using module: ping. my hosts file looks like below:

[groupA]
HostA ansible_connection=ssh ansible_user=userA

command: ansible -i hosts -m ping all Manually I am able to ssh successfully using same userA on HostA, but not via ansible
Debug logs from ansible:

No config file found; using defaults
Loaded callback minimal of type stdout, v2.0
ESTABLISH SSH CONNECTION FOR USER: userA
SSH: EXEC ssh -C -vvv -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=userA -o ConnectTimeout=10 HostA '/bin/sh -c '"'"'( umask 77 && mkdir -p "echo /tmp/ansible-userB/ansible-tmp-1473143642.15-125405279117948" && echo ansible-tmp-1473143642.15-125405279117948="echo /tmp/ansible-userB/ansible-tmp-1473143642.15-125405279117948" ) && sleep 0'"'"''

Source Host O.S details:

LSB Version:
:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer Description: Red Hat
Enterprise Linux Server release 6.8 (Santiago) Release: 6.8
Codename: Santiago

Target Host O.S details:

bash-4.1$ lsb_release -a
LSB Version:
:base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.8 (Santiago)
Release:
6.8
Codename: Santiago

EDIT: Manual commands:

ssh UserA@HostA
//Some lines of sshing to the remote host
-sh$: hostname -f
HostA
-sh$:

EDIT2: Output from running ssh: EXEC command

OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to hostA [IP port] port 22. debug2: fd 3 setting O_NONBLOCK debug1: fd 3 clearing O_NONBLOCK debug1: Connection established. debug3: timeout: 9924 ms remain after connect debug1: identity file /home/userB/.ssh/identity type -1 debug1: identity file /home/userB/.ssh/identity-cert type -1 debug3: Not a RSA1 key file /home/userB/.ssh/id_rsa. debug2: key_type_from_name: unknown key type '-----BEGIN' debug3: key_read: missing keytype debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug3: key_read: missing whitespace debug2: key_type_from_name: unknown key type '-----END' debug3: key_read: missing keytype debug1: identity file /home/userB/.ssh/id_rsa type 1 debug1: identity file /home/userB/.ssh/id_rsa-cert type -1 debug1: identity file /home/userB/.ssh/id_dsa type -1 debug1: identity file /home/userB/.ssh/id_dsa-cert type -1 debug1: identity file /home/userB/.ssh/id_ecdsa type -1 debug1: identity file /home/userB/.ssh/id_ecdsa-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug2: fd 3 setting O_NONBLOCK debug1: SSH2_MSG_KEXINIT sent debug3: Wrote 960 bytes for a total of 981 debug1: SSH2_MSG_KEXINIT received debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: [email protected],zlib,none debug2: kex_parse_kexinit: [email protected],zlib,none debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: ssh-rsa,ssh-dss debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: none,[email protected] debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: debug2: kex_parse_kexinit: first_kex_follows 0 debug2: kex_parse_kexinit: reserved 0 debug2: mac_setup: found hmac-md5 debug1: kex: server->client debug2: mac_setup: found hmac-md5 debug1: kex: client->server debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP debug3: Wrote 24 bytes for a total of 1005 debug2: dh_gen_key: priv key bits set: 123/256 debug2: bits set: 506/1024 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug3: Wrote 144 bytes for a total of 1149 debug3: check_host_in_hostfile: host hostA filename /home/userB/.ssh/known_hosts debug3: check_host_in_hostfile: host hostA filename /home/userB/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug3: check_host_in_hostfile: host IP port filename /home/userB/.ssh/known_hosts debug3: check_host_in_hostfile: host IP port filename /home/userB/.ssh/known_hosts debug3: check_host_in_hostfile: match line 1 debug1: Host 'hostA' is known and matches the RSA host key. debug1: Found key in /home/userB/.ssh/known_hosts:1 debug2: bits set: 505/1024 debug1: ssh_rsa_verify: signature correct debug2: kex_derive_keys debug2: set_newkeys: mode 1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug3: Wrote 16 bytes for a total of 1165 debug2: set_newkeys: mode 0 debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug3: Wrote 48 bytes for a total of 1213 debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/userB/.ssh/identity ((nil)) debug2: key: /home/userB/.ssh/id_rsa (0x7ffb0551e430) debug2: key: /home/userB/.ssh/id_dsa ((nil)) debug2: key: /home/userB/.ssh/id_ecdsa ((nil)) debug3: Wrote 64 bytes for a total of 1277 debug3: input_userauth_banner

debug1: Authentications that can continue: debug3: start over, passed a different list debug3: preferred debug3: authmethod_lookup gssapi-with-mic debug3: remaining preferred: debug3: authmethod_is_enabled debug1: Next authentication method: debug3: Trying to reverse map address IP port. debug1: Unspecified GSS failure. Minor code may provide more information Credentials cache file '/tmp/krb5cc_' not found

debug1: Unspecified GSS failure. Minor code may provide more information Credentials cache file '/tmp/krb5cc_' not found

debug1: Unspecified GSS failure. Minor code may provide more information

debug1: Unspecified GSS failure. Minor code may provide more information Credentials cache file '/tmp/krb5cc_' not found

debug2: we did not send a packet, disable method debug3: authmethod_lookup gssapi-keyex debug3: remaining preferred: debug3: authmethod_is_enabled gssapi-keyex debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug2: we did not send a packet, disable method debug3: authmethod_lookup publickey debug3: remaining preferred: ,publickey debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/userB/.ssh/identity debug3: no such identity: /home/userB/.ssh/identity debug1: Offering public key: /home/userB/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug3: Wrote 368 bytes for a total of 1645 debug1: Server accepts key: pkalg ssh-rsa blen 277 debug2: input_userauth_pk_ok: debug3: sign_and_send_pubkey: debug1: read PEM private key done: type RSA debug3: Wrote 640 bytes for a total of 2285 debug1: Enabling compression at level 6. debug1: Authentication succeeded (publickey). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Requesting [email protected] debug1: Entering interactive session. debug3: Wrote 112 bytes for a total of 2397 debug2: callback start debug2: client_session2_setup: id 0 debug2: channel 0: request pty-req confirm 1 debug1: Sending environment. debug3: Ignored env debug3: Ignored env debug3: Ignored env MANPATH debug3: Ignored env debug3: Ignored env HOSTNAME debug3: Ignored env ANSIBLE_HOST_KEY_CHECKING debug3: Ignored env ANSIBLE_SSH_ARGS debug3: Ignored env debug3: Ignored env TERM debug3: Ignored env SHELL debug3: Ignored env HISTSIZE debug3: Ignored env QTDIR debug3: Ignored env OLDPWD debug3: Ignored env QTINC debug3: Ignored env USER debug3: Ignored env ANSIBLE_REMOTE_TEMP debug3: Ignored env LS_COLORS debug3: Ignored env debug3: Ignored env TMOUT debug3: Ignored env debug3: Ignored env PAGER debug3: Ignored env PATH debug3: Ignored env debug3: Ignored env PWD debug3: Ignored env JAVA_HOME debug3: Ignored env LMFILES debug3: Ignored env EFS_SERVERNAME debug3: Ignored env EDITOR debug1: Sending env LANG = en_US.utf8 debug2: channel 0: request env confirm 0 debug3: Ignored env MODULEPATH debug3: Ignored env debug3: Ignored env LOADEDMODULES debug3: Ignored env ANSIBLE_SCP_IF_SSH debug3: Ignored env ANSIBLE_TRANSPORT debug3: Ignored env HISTCONTROL debug3: Ignored env debug3: Ignored env SHLVL debug3: Ignored env HOME debug3: Ignored env debug3: Ignored env PYTHONPATH debug3: Ignored env PBUSER debug3: Ignored env LOGNAME debug3: Ignored env QTLIB debug3: Ignored env CVS_RSH debug3: Ignored env LESSOPEN debug3: Ignored env EFS_PLATFORM64 debug3: Ignored env G_BROKEN_FILENAMES debug3: Ignored env BASH_FUNC_append() debug3: Ignored env BASH_FUNC_addpath() debug3: Ignored env BASH_FUNC_module() debug3: Ignored env BASH_FUNC_prepend() debug3: Ignored env BASH_FUNC_delpath() debug3: Ignored env BASH_FUNC_showpath() debug3: Ignored env _ debug2: channel 0: request shell confirm 1 debug2: fd 3 setting TCP_NODELAY debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug3: Wrote 320 bytes for a total of 2717 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel 0: rcvd adjust 2097152 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0 Last login: Tue Sep 6 07:24:55 2016 from hostB

1
Is there an error message or it just hangs? What's the OS on target host?Konstantin Suvorov
What type of authentication do you use?techraf
@KonstantinSuvorov It just hangs. But via manual ssh it does not hangs. I am using ssh no-pass authenticationMrunal Gosar
What's happen if you execute line after SSH: EXEC manually from shell?Konstantin Suvorov
sorry is that a command u would want me to execute. I have executed the commands as posted in OP.Mrunal Gosar

1 Answers

0
votes

Did you try to skip the authentication of ssh? In the file /etc/ssh/ssh_config or ~/.ssh/config, add following lines.

Host *
    StrictHostKeyChecking no

or add following lines in the ansible.cfg

[defaults]
host_key_checking = False