首页 文章

ansible无法ssh但手动ssh成功

提问于
浏览
1

我正在尝试使用模块ping远程主机:ping . 我的hosts文件如下所示:

[groupA] HostA ansible_connection = ssh ansible_user = userA

命令: ansible -i hosts -m ping all 手动我能够在HostA上使用相同的userA成功ssh,但不能通过ansible
来自ansible的调试日志:

找不到配置文件;使用默认值加载回调最小类型为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'”'''''

源主机O.S详情:

LSB版本:: 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分销商ID:RedHatEnterpriseServer描述:红帽企业Linux服务器版本6.8(圣地亚哥)版本:6.8代号:Santiago

目标主机O.S详情:

bash-4.1 $ lsb_release -a LSB版本:: 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分销商ID:RedHatEnterpriseServer描述:红帽企业Linux服务器版本6.8(圣地亚哥)版本:6.8代号:Santiago

编辑:手动命令:

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

EDIT2:运行ssh:EXEC命令的输出

OpenSSH_5.3p1,OpenSSL 1.0.1e-fips 2013年2月11日debug1:读取配置数据/ etc / ssh / ssh_config debug1:应用* debug2的选项:ssh_connect:needpriv 0 debug1:连接到hostA [IP端口]端口22. debug2 :fd 3设置O_NONBLOCK debug1:fd 3清除O_NONBLOCK debug1: Build 连接 . debug3:timeout:连接debug1后保留9924 ms:身份文件/home/userB/.ssh/identity类型-1 debug1:身份文件/home/userB/.ssh/identity-cert类型-1 debug3:不是RSA1密钥文件/home/userB/.ssh/id_rsa . debug2:key_type_from_name:未知密钥类型'----- BEGIN'debug3:key_read:缺少keytype debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:missing空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3 :key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read :缺少空白debug3:key_read:缺少空白debug3:key_read:缺少空白debug3:key_read:mi ssing whitespace debug2:key_type_from_name:未知密钥类型'----- END'debug3:key_read:缺少密钥类型debug1:标识文件/home/userB/.ssh/id_rsa类型1 debug1:标识文件/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类型-1 debug1:身份文件/home/userB/.ssh/id_ecdsa-cert类型-1 debug1:远程协议版本2.0,远程软件版本OpenSSH_5.3 debug1:匹配:OpenSSH_5.3 pat OpenSSH * debug1:启用协议2.0的兼容模式debug1:本地版本字符串SSH-2.0-OpenSSH_5.3 debug2:fd 3设置O_NONBLOCK debug1:SSH2_MSG_KEXINIT发送debug3:编写了960个字节,共981个debug1:SSH2_MSG_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:debug2:kex_parse_kexinit:zlib @ope nssh.com,zlib,none debug2:kex_parse_kexinit:zlib @ openssh.com,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-DSSdebug2:kex_parse_kexinit:debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:none,zlib @ openssh.com debug2:kex_parse_kexinit:none,zlib @ openssh.com debug2:kex_parse_kexinit:debug2:kex_parse_kexinit:debug2:kex_parse_kexinit: first_kex_follows 0 DEBUG2:kex_parse_kexinit:预留0 DEBUG2:mac_setup:发现HMAC-MD5 DEBUG1:KEX:服务器 - >客户端DEBUG2:mac_setup:发现HMAC-MD5 DEBUG1:KEX:客户端 - >服务器DEBUG1:SSH2_MSG_KEX_DH_GEX_REQUEST(1024 <1024 <8192)发送DEBUG1:期待SSH2_MSG_KEX_DH_GEX_GROUP debug3:写24个字节,总共1005 DEBUG2:dh_gen_key:PRIV键位设置:二百五十六分之一百二十三DEBUG2:位设置:一千○二十四分之五百○六DEBUG1:SSH2_MSG_KEX_DH_GEX_INIT发送DEBUG1:期待SSH2_MSG_KEX_DH_GEX_REPLY debug3:写144个字节为一个总计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_hos tfile:比赛线路1 debug3:check_host_in_hostfile:主机IP端口名/home/userB/.ssh/known_hosts debug3:check_host_in_hostfile:主机IP端口名/home/userB/.ssh/known_hosts debug3:check_host_in_hostfile:比赛线路1个DEBUG1:主机' hostA'已知并与RSA主机密钥匹配 . DEBUG1:在/home/userB/.ssh/known_hosts:1 DEBUG2实测键:位设置:一千○二十四分之五百○五DEBUG1:ssh_rsa_verify:签名正确DEBUG2:kex_derive_keys DEBUG2:set_newkeys:模式1个DEBUG1:SSH2_MSG_NEWKEYS发送DEBUG1:期待SSH2_MSG_NEWKEYS debug3:写16个字节,总共1165 DEBUG2:set_newkeys:模式0 DEBUG1:SSH2_MSG_NEWKEYS接收DEBUG1:SSH2_MSG_SERVICE_REQUEST发送debug3:写48个字节,总共1213 DEBUG2的:service_accept:SSH-USERAUTH DEBUG1:SSH2_MSG_SERVICE_ACCEPT接收DEBUG2:键:/家庭/用户B /.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:写了64个字节,总共1277个debug3:input_userauth_banner debug1:可以继续的认证:debug3:重新开始,传递了不同的列表debug3:首选debug3:authmethod_lookup gssapi-with -mic debug3:保留首选:debug3:authmethod_is_enabled debug1:Next authenticnticatio n方法:debug3:尝试反转映射地址的IP端口 . debug1:未指定的GSS失败 . 次代码可能提供更多信息Credentials缓存文件'/ tmp / krb5cc_'未找到debug1:未指定的GSS失败 . 次代码可能提供更多信息Credentials缓存文件'/ tmp / krb5cc_'未找到debug1:未指定的GSS失败 . 次要代码可能提供更多信息debug1:未指定的GSS失败 . 次要代码可提供更多信息凭证高速缓存文件“/ tmp目录/ krb5cc_”未找到DEBUG2:我们没有发送数据包,禁用方法debug3:authmethod_lookup GSSAPI-keyex debug3:剩余的首选:debug3:authmethod_is_enabled GSSAPI-keyex DEBUG1:下一步的验证方法:gssapi-keyex debug1:无效密钥交换上下文debug2:我们没有发送数据包,禁用方法debug3:authmethod_lookup publickey debug3:剩余首选:,publickey debug3:authmethod_is_enabled publickey debug1:下一个身份验证方法:publickey debug1:尝试私钥: /home/userB/.ssh/identity debug3:没有这样的身份:/home/userB/.ssh/identity debug1:提供公钥:/home/userB/.ssh/id_rsa debug3:send_pubkey_test debug2:我们发送了一个publickey数据包,等待回复debug3:编写了368个字节,总共1645个debug1:服务器接受密钥:pkalg ssh-rsa blen 277 debug2:input_userauth_pk_ok:debug3:sign_and_send_pubkey:debug1:读取PEM私钥完成:输入RSA debug3:写入640测试共2285次debug1:在级别6启用压缩.debug1:身份验证成功(publickey) . debug1:channel 0:new [client-session] debug3:ssh_session2_open:channel_new:0 debug2:channel 0:send open debug1:request no-more-sessions@openssh.com debug1:进入交互式会话 . debug3:编写了112个字节,共2397个debug2:callback start debug2:client_session2_setup:id 0 debug2:channel 0:request pty-req confirm 1 debug1:发送环境 . debug3:忽略env debug3:忽略env debug3:忽略env MANPATH debug3:忽略env debug3:忽略env HOSTNAME debug3:忽略env ANSIBLE_HOST_KEY_CHECKING debug3:忽略env ANSIBLE_SSH_ARGS debug3:忽略env debug3:忽略env TERM debug3:忽略env SHELL debug3:忽略env HISTSIZE debug3:忽略env QTDIR debug3:忽略env OLDPWD debug3:忽略env QTINC debug3:忽略env USER debug3:忽略env ANSIBLE_REMOTE_TEMP debug3:忽略env LS_COLORS debug3:忽略env debug3:忽略env TMOUT debug3:忽略env debug3:忽略env PAGER debug3:忽略env PATH debug3:忽略ENV debug3:忽略ENV PWD debug3:忽略ENV JAVA_HOME debug3:忽略ENV LMFILES debug3:忽略ENV EFS_SERVERNAME debug3:忽略ENV EDITOR DEBUG1:发送ENV LANG = en_US.utf8 DEBUG2:通道0:请求ENV确认0 debug3:忽略env MODULEPATH debug3:忽略env debug3:忽略env LOADEDMODULES debug3:忽略env ANSIBLE_SCP_IF_SSH debug3:忽略env ANSIBLE_TRANSPORT debug3:忽略env HISTCONTROL debug3:忽略env debug3:忽略env SHLVL debug3:忽略env HOME debug3:忽略env debug3:忽略env PYTHONPATH debug3 :忽略ENV PBUSER debug3:忽略ENV LOGNAME debug3:忽略ENV QTLIB debug3:忽略ENV CVS_RSH debug3:忽略ENV LESSOPEN debug3:忽略ENV EFS_PLAT FORM64 debug3:忽略的env G_BROKEN_FILENAMES debug3:忽略的env BASH_FUNC_append()debug3:忽略的env BASH_FUNC_addpath()debug3:忽略的env BASH_FUNC_module()debug3:忽略的env BASH_FUNC_prepend()debug3:忽略的env BASH_FUNC_delpath()debug3:忽略的env BASH_FUNC_showpath()debug3:忽略ENV _ DEBUG2:通道0:请求壳确认1个DEBUG2:FD 3设置TCP_NODELAY DEBUG2:回调完成DEBUG2:通道0:开放确认RWindow对象0 RMAX 32768 debug3:写320个字节,总共2717 DEBUG2:channel_input_status_confirm:类型99标识0 DEBUG2:PTY分配请求信道0 DEBUG2接受:通道0:RCVD调整2097152 DEBUG2:channel_input_status_confirm:99类型ID 0 DEBUG2:从hostB的星期二9月6日7时24分55秒2016:接受通道0上上次登录壳请求

1 回答

  • 0

    您是否尝试跳过ssh的身份验证?在文件/ etc / ssh / ssh_config或〜/ .ssh / config中,添加以下行 .

    Host *
        StrictHostKeyChecking no
    

    或者在ansible.cfg中添加以下行

    [defaults]
    host_key_checking = False
    

相关问题