找回密码
 注册
查看: 559|回复: 2

ansible FAILED | rc=-1 >> to use the 'ssh' connection type with passwords

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2023-2-11 11:39:29 | 显示全部楼层 |阅读模式
[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all
& ~& m. F+ g/ S9 a5 s) Q[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. # r, z# S. \" G2 e
Current version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
6 l# Z( k' V" T/ }# V% u& Fwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting 2 B0 A3 ^' |1 i9 H3 `
deprecation_warnings=False in ansible.cfg.. j; A. J4 b3 O" n
/usr/local/lib/python3.6/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
' s+ Q& y! W& X7 _  from cryptography.exceptions import InvalidSignature
9 D/ O6 Y4 W- |4 v, u6 K[WARNING]: Unhandled error in Python interpreter discovery for host 192.168.13.165: to use the 'ssh' connection
5 U/ k1 i* R# w; B; ptype with passwords, you must install the sshpass program* D0 l7 `8 V# f2 J- X9 Q, I: |% @
192.168.13.165 | FAILED | rc=-1 >>
( {1 {9 @( Z4 K) h0 Zto use the 'ssh' connection type with passwords, you must install the sshpass program( H! k* A5 P& q
[root@controller ~]# dnf install -y sshpass - A6 B" I4 i) t/ M% M+ U. V. [
Last metadata expiration check: 0:36:36 ago on Sat 11 Feb 2023 11:01:32 AM CST.3 x3 `1 k1 c$ ~0 i0 _' r
Dependencies resolved.5 `! _* n8 U* K* X! B& R2 i
==================================================================================================================9 j  d0 {2 X4 e; i& @
Package                  Architecture            Version                        Repository                  Size; D0 d2 w, E" G5 V3 w
==================================================================================================================, u. L2 m1 |; d( d+ B7 I" h, d
Installing:
, V0 N: U$ ]; Z% I9 F% ^ sshpass                  x86_64                  1.09-4.el8                     appstream                   30 k
* {) q; ?% G8 x$ A) Z
' |/ g- q1 p% S1 ~7 y% STransaction Summary" K) B1 X# v9 q% b
==================================================================================================================
# @) C/ [: K3 k. Y* V: \; T  w( dInstall  1 Package0 F" b3 B% p4 x8 ?5 c6 Y! H

$ S1 \/ l' ^3 S" m3 y5 e4 t) VTotal download size: 30 k  o8 T4 Y; x8 H6 H3 d- L* [0 ]3 x/ c
Installed size: 43 k
5 d2 t2 ]6 C) d6 A/ v; l: g4 ^Downloading Packages:2 j# L" [; o, S% r
sshpass-1.09-4.el8.x86_64.rpm                                                      24 kB/s |  30 kB     00:01   
+ c+ K7 u8 V0 ]------------------------------------------------------------------------------------------------------------------- x6 H  K% f3 q: Z3 B, V; f  o
Total                                                                              12 kB/s |  30 kB     00:02     # o8 w. F) I! x$ E, _5 ]  b  d
Running transaction check. ^8 h; U/ o6 H& A, d
Transaction check succeeded.5 a1 a  s; X! K2 G2 ~4 i+ f! p1 |
Running transaction test
& b7 z8 e, ?) _; Z# kTransaction test succeeded.. ~4 b+ }- k6 ]! Q1 z
Running transaction
7 a/ A1 g  f4 ^: w( f" Z  Preparing        :                                                                                          1/1 1 q' }) `5 I" n# T$ E: r# [
  Installing       : sshpass-1.09-4.el8.x86_64                                                                1/1 " G- X. Z' @  v$ ^& D
  Running scriptlet: sshpass-1.09-4.el8.x86_64                                                                1/1 % A4 ^- n' ~9 ?0 O
  Verifying        : sshpass-1.09-4.el8.x86_64                                                                1/1
' s* L/ L; @8 w6 j; S
$ d5 ]3 @; u, e: ^Installed:, |" I0 _" p% Y) [9 T; I% C) _
  sshpass-1.09-4.el8.x86_64                                                                                       8 U2 D0 n% a$ p' H

6 H* A) g( p( T6 j; W4 b' d  j) AComplete!  J- V3 ]) Q' V* B
[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all, ~& J% b2 a. }) T; G; J
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
8 r3 d# Y( o4 N5 t& k  H; C6 SCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
  _( {0 R! |0 ^: Jwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
" |( Z. w) j6 \deprecation_warnings=False in ansible.cfg.6 v* c3 R5 r, I6 F( A( l
/usr/local/lib/python3.6/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.* v. z, m* Q9 f* Y4 r6 U) ^6 _6 L
  from cryptography.exceptions import InvalidSignature
) e* o  b- K7 O; o1 C) X' _192.168.13.165 | CHANGED | rc=0 >>& A% X# w4 |4 i  _1 X8 j/ \! D& C% q
total 20. X; S1 n, c2 B! I6 s
dr-xr-xr-x.  17 root root  244 Feb 10 21:00 .
3 q$ @( M* c. s( zdr-xr-xr-x.  17 root root  244 Feb 10 21:00 ..; T! i4 W4 B5 g, Q
-rw-r--r--    1 root root    0 Feb 10 21:00 .autorelabel
" P- P/ X* Q9 L9 g5 D/ dlrwxrwxrwx.   1 root root    7 Jun 22  2021 bin -> usr/bin
. a2 D! Q# |- k- k# X% i, O! edr-xr-xr-x.   5 root root 4096 Apr 18  2022 boot8 |9 z  x- t" D" V
drwxr-xr-x   20 root root 3180 Feb 11 09:29 dev
7 v* W" i0 R3 Y( J" h& ~8 idrwxr-xr-x.  85 root root 8192 Feb 11 11:38 etc0 ~; S9 O8 G4 y$ E! S
drwxr-xr-x.   2 root root    6 Jun 22  2021 home  L  j' z1 W8 \$ d8 l  }
lrwxrwxrwx.   1 root root    7 Jun 22  2021 lib -> usr/lib# ?" g7 {  {5 l7 z1 R4 r
lrwxrwxrwx.   1 root root    9 Jun 22  2021 lib64 -> usr/lib64; `, B" L8 w2 [" G) q
drwxr-xr-x.   2 root root    6 Jun 22  2021 media! K) c1 ?" \+ V7 J
drwxr-xr-x.   3 root root   18 Apr 18  2022 mnt! _& f* U0 a' b
drwxr-xr-x.   2 root root    6 Jun 22  2021 opt
! `) U+ N% R3 u6 S$ mdr-xr-xr-x  171 root root    0 Feb 11 09:29 proc8 U  r* x1 A& r
dr-xr-x---.   5 root root  210 Feb 11 11:35 root
' m: ^9 t( u% T( xdrwxr-xr-x   27 root root  780 Feb 11 11:10 run
% ?, R: L" k6 Z" v# y$ i( D  _# xlrwxrwxrwx.   1 root root    8 Jun 22  2021 sbin -> usr/sbin0 O" J2 M' H7 G) P) [! N
drwxr-xr-x.   2 root root    6 Jun 22  2021 srv  D* B( k9 [$ u0 U8 k0 O
dr-xr-xr-x   13 root root    0 Feb 11 09:29 sys
" U, J  c  H# W; g6 y7 rdrwxrwxrwt.  15 root root 4096 Feb 11 11:38 tmp( G0 {7 X5 B; h* k
drwxr-xr-x.  12 root root  144 Apr 18  2022 usr
5 D' g4 r: D0 [% pdrwxr-xr-x.  20 root root  278 May 19  2022 var  y2 m) |# \7 I& @1 t
+ u8 W" J( a5 ?
5 F( a2 @. K& C1 h4 V% I& [3 Q

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 11:45:17 | 显示全部楼层
[root@controller ~]# ansible -i inventory -m ping contol6 X! I+ e- M9 E# }
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
+ P" i! `0 F, f$ v% Q  q3 X2 T) a& RCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature   ~: M5 f8 e- d/ m" a
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
4 H6 h, T7 S8 udeprecation_warnings=False in ansible.cfg.
2 p6 `( p4 ^8 |; x- {' b8 L/usr/local/lib/python3.6/site-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
' H; s$ f  C3 x' [, Z  from cryptography.exceptions import InvalidSignature5 W0 g& z0 X# s: {
192.168.13.165 | SUCCESS => {
, [; k1 B! j1 L1 A+ l* f    "ansible_facts": {
4 C6 x( U+ E/ [        "discovered_interpreter_python": "/usr/libexec/platform-python"
3 p$ ]9 p  r/ C, e* h    },
4 Y/ E! L  h' \4 S' X    "changed": false,4 }$ F/ J5 ^' k2 e8 B3 t% B+ S5 {
    "ping": "pong"; K" W( n* r! l* |  h1 N9 x( n9 M
}
) V; r. g; H( G

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 16:15:43 | 显示全部楼层
什么情况会出现要求安装sshpass:
+ w' S# i( Z7 U% y- R9 u& t- C) o- A
  如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说. y/ H* Y( H- J

; d0 _1 u! c9 A  1、在运行ansible的主机上要与被控机建立ssh信任。' x2 J# L. o( h4 ^; F$ ]1 [
- V8 r# p$ q" Z% C+ d4 [; J) M; e  m
  2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 03:23 , Processed in 0.027751 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表