ansible无法ssh但手动ssh成功

时间:2016-09-06 06:41:54

标签: ssh ansible

我正在尝试使用module ping ping远程主机。我的主机文件如下所示:

  

[groupA]
HostA ansible_connection = ssh ansible_user = userA

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

  

找不到配置文件;使用默认值
加载回调最小值   type stdout,v2.0
为用户建立SSH连接:   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" )&&   睡0'''''

Source Host 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说明:Red Hat
  Enterprise Linux Server 6.8版(圣地亚哥)版本:6.8
  代号:圣地亚哥

Target Host O.S详情:

  

bash-4.1 $ lsb_release -a
  LSB版本:
  :碱-4.0-AMD64:碱-4.0-noarch:芯-4.0-AMD64:芯-4.0-noarch:图形-4.0-AMD64:图形-4.0-noarch:印刷-4.0-AMD64:印刷-4.0-noarch   
分销商ID:RedHatEnterpriseServer
描述:红色   Hat Enterprise Linux Server 6.8版(圣地亚哥)
发布:
  6.8
代号:圣地亚哥

编辑:手动命令:

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:已建立连接。 debug3:timeout:9924 ms   连接debug1后保留:身份文件/home/userB/.ssh/identity   type -1 debug1:identity file /home/userB/.ssh/identity-cert type -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:缺少空格   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:missing   空白debug3:key_read:缺少空白debug3:key_read:   缺少空白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:缺少空白debug2:key_type_from_name:未知密钥   键入' ----- END' debug3:key_read:缺少keytype debug1:identity   file /home/userB/.ssh/id_rsa type 1 debug1:identity file   /home/userB/.ssh/id_rsa-cert类型-1 debug1:身份文件   /home/userB/.ssh/id_dsa type -1 debug1:identity file   /home/userB/.ssh/id_dsa-cert类型-1 debug1:身份文件   /home/userB/.ssh/id_ecdsa类型-1 debug1:身份文件   /home/userB/.ssh/id_ecdsa-cert type -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 @ openssh.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:   保留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,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: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)发送debug1:期待   SSH2_MSG_KEX_DH_GEX_GROUP debug3:写入24个字节,共计1005个   debug2:dh_gen_key:priv key bits set:123/256 debug2:bits set:   506/1024 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文件名/home/userB/.ssh/known_hosts debug3:   check_host_in_hostfile:match line 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:bits set中的键:   505/1024 debug1:ssh_rsa_verify:签名正确debug2:   kex_derive_keys debug2:set_newkeys:mode 1 debug1:SSH2_MSG_NEWKEYS   发送debug1:期待SSH2_MSG_NEWKEYS debug3:为a写了16个字节   共有1165个debug2:set_newkeys:mode 0 debug1:SSH2_MSG_NEWKEYS   收到debug1:SSH2_MSG_SERVICE_REQUEST发送debug3:写了48个字节   共有1213个debug2:service_accept:ssh-userauth debug1:   SSH2_MSG_SERVICE_ACCEPT收到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:写了64个字节   共有1277个debug3:input_userauth_banner

     

debug1:可以继续的身份验证:debug3:重新开始,传递   另一个列表debug3:首选debug3:authmethod_lookup   gssapi-with-mic debug3:保留首选:debug3:   authmethod_is_enabled debug1:下一个身份验证方法:debug3:   试图反转映射地址IP端口。 debug1:未指定的GSS   失败。次要代码可能会提供更多信息Credentials缓存   档案' / tmp / krb5cc _'找不到

     

debug1:未指定的GSS失败。次要代码可能提供更多   信息凭证缓存文件' / 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:身份验证   成功(公钥)。 debug1:channel 0:new [client-session] debug3:   ssh_session2_open:channel_new:0 debug2:channel 0:send open debug1:   请求no-more-sessions@openssh.com debug1:输入交互式   会话。 debug3:写了112个字节,共2397个debug2:回调   启动debug2:client_session2_setup:id 0 debug2:channel 0:request   pty-req确认1 debug1:发送环境。 debug3:忽略环境   debug3:忽略env debug3:忽略env MANPATH debug3:忽略env   debug3:忽略env HOSTNAME debug3:忽略环境   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   编辑器debug1:发送env LANG = en_US.utf8 debug2:channel 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_PLATFORM64 debug3:忽略环境   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:请求shell确认1 debug2:fd 3   设置TCP_NODELAY debug2:回调完成debug2:通道0:打开   确认rwindow 0 rmax 32768 debug3:共写了320个字节   2717 debug2:channel_input_status_confirm:类型99 id 0 debug2:PTY   在通道0上接受的分配请求debug2:通道0:rcvd   调整2097152 debug2:channel_input_status_confirm:输入99 id 0   debug2:在通道0上接受shell请求上次登录:9月6日星期二   2016年07:24:55来自hostB

1 个答案:

答案 0 :(得分:0)

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

@media only screen and (max-width: 640px) {
    
    /* Force table to not be like tables anymore */
	.no-more-tables table, 
	.no-more-tables thead, 
	.no-more-tables tbody, 
	.no-more-tables th, 
	.no-more-tables td, 
	.no-more-tables tr { 
		display: block; 
	}
 
	/* Hide table headers (but not display: none;, for accessibility) */
	.no-more-tables thead tr { 
		position: absolute;
		top: -9999px;
		left: -9999px;
	}
 .hdv {
   width: 46%;
   padding: 5px;
   display: inline-block;
  }
  .dsp {
    font-weight: bold;
  }
	.no-more-tables tr { border: 1px solid #ccc; }
 
	.no-more-tables td { 
		/* Behave  like a "row" */
    width: 100%;
		border: none;
		border-bottom: 1px solid #eee;  
		white-space: normal;
		text-align:left;
	}
 

	/*
	Label the data
	*/
}
.cf {
  width:100%;
}
.cf > tr > th {
  text-align: left;
}
.cf > tbody > tr > td {
  height: 25px;
}
.newvariation > td > input:focus {
  outline:0px !important;
  -webkit-appearance:none;
  box-shadow: none;
  -moz-box-shadow: none;
  -webkit-box-shadow: none;
}
.vv > div {
  margin: 5px;
  display: inline-block;
  cursor: pointer;
}
@media only screen and (min-width: 641px) {
 .dsp {
   visibility: hidden;
   display: none;
  }
}

或在ansible.cfg

中添加以下行
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="no-more-tables">
            <table class="table-bordered table-striped table-condensed cf">
        		<thead class="cf">
        			<tr>
        				<th class="c1"><input type="checkbox" class="checkAll"/></th>
        				<th class="c2">Product</th>
        				<th class="c3" contenteditable="true">Variation 1</th>
        				<th class="c4" contenteditable="true">Variation 2</th>
        				<th class="c5" contenteditable="true">Variation 3</th>
        				<th class="c6" contenteditable="true">Variation 4</th>
        				<th class="c7">Quantity</th>
        				<th class="c8">Price</th>
        			</tr>
        		</thead>
        		<tbody>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr>
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>
        			<tr class="removeAttr">
        				<td><input type="checkbox" class="selectall" /></td>
                <td>
        				  <span class="hdv dsp">Product</span>
                  <span class="hdv" contenteditable="true">iPhone 7 Plus</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 1</span>
                  <span class="hdv" contenteditable="true">64GB</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 2</span>
                  <span class="hdv" contenteditable="true">Matte Black</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 3</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp" contenteditable="true">Variation 4</span>
                  <span class="hdv" contenteditable="true">--</span>
                </td>
                <td>
        				  <span class="hdv dsp">Quantity</span>
                  <span class="hdv" contenteditable="true">3</span>
                </td>
                <td>
        				  <span class="hdv dsp">Price</span>
                  <span class="hdv" contenteditable="true">$964.36</span>
                </td>
        			</tr>

        		</tbody>
        	</table>
        </div>
<div class="vv">
  <div>+ Add new Line</div>
  <div class="gone">- Remove selected</div>
</div>