找回密码
 注册
查看: 555|回复: 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
8 ]* S5 b+ y( ]; n4 B: z[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
1 X$ x5 n0 {! @0 L/ WCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
' f$ Y7 p$ K0 w# Twill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
/ l9 P6 @2 x+ r% Y- q* Y! g0 hdeprecation_warnings=False in ansible.cfg.
5 p: Z) a. ?% _9 z/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.1 X, D: [$ e; x7 u. e: Z7 A6 n
  from cryptography.exceptions import InvalidSignature; o- X+ o7 N" V$ P7 S4 d7 H
[WARNING]: Unhandled error in Python interpreter discovery for host 192.168.13.165: to use the 'ssh' connection3 J; s9 t2 t1 U9 K+ {
type with passwords, you must install the sshpass program5 z# S* u; a! m; H8 l
192.168.13.165 | FAILED | rc=-1 >>
* {- @4 z( e0 @5 T5 L& Pto use the 'ssh' connection type with passwords, you must install the sshpass program" {. j4 @# k  P6 U0 u9 F
[root@controller ~]# dnf install -y sshpass ' K& A! p, i- J) W7 B. }2 h  s& r
Last metadata expiration check: 0:36:36 ago on Sat 11 Feb 2023 11:01:32 AM CST.
/ ?+ m' e: N) _0 l1 O$ r4 r3 s: mDependencies resolved.8 B  k/ ^3 P2 d" o& C2 q$ R
==================================================================================================================; S2 u/ H7 B- ~9 }5 A. X
Package                  Architecture            Version                        Repository                  Size$ w9 }5 f8 t' J" j
==================================================================================================================
7 @; }. B1 ~! a4 l; t: V. }% eInstalling:( @: E. b' C" c) |) E7 i* q0 R& e3 ]
sshpass                  x86_64                  1.09-4.el8                     appstream                   30 k
+ z' F" ?* r  b/ ^# S. K( i( ~2 x, ~' u
* {- m! P" u/ g" S; s7 |$ @Transaction Summary% G, ~6 L) T( [* Z
==================================================================================================================7 X' B) W/ w( H7 ?0 E& N' `' j+ p
Install  1 Package
* q8 _6 I, D% S
# f+ Y6 f, [# B+ m) \Total download size: 30 k+ y: v# f8 S, h1 M
Installed size: 43 k
; H8 J$ f7 _9 ~/ P. [: }9 ~Downloading Packages:$ D9 L! w3 ]" B- f6 B7 e# D
sshpass-1.09-4.el8.x86_64.rpm                                                      24 kB/s |  30 kB     00:01    " W' n+ U# _% A7 l' S& M
------------------------------------------------------------------------------------------------------------------
, F! i. `& q- x9 \7 m! nTotal                                                                              12 kB/s |  30 kB     00:02     7 c2 F; r4 k, T1 O8 g7 e6 B  u) x& s
Running transaction check
7 ?8 H8 A+ E! `' aTransaction check succeeded.
% C; U: X6 f% ]0 B/ m) \1 g( ~* k/ k0 fRunning transaction test% s* T3 I: ]8 e0 e$ S
Transaction test succeeded.
5 {: J, @. B1 B5 D0 y: D: b7 vRunning transaction2 i/ C0 J  @9 [
  Preparing        :                                                                                          1/1 / L6 H: L7 i  M+ z
  Installing       : sshpass-1.09-4.el8.x86_64                                                                1/1
+ U4 l) q4 O% H0 v  Running scriptlet: sshpass-1.09-4.el8.x86_64                                                                1/1
- @: M8 T8 ?9 P) v3 @& `5 M' k  Verifying        : sshpass-1.09-4.el8.x86_64                                                                1/1
7 n- F& M# y! H
( O' i, a5 ^' o$ M( ?3 z: gInstalled:
* @* e; B. e& o- N: d  sshpass-1.09-4.el8.x86_64                                                                                       
1 X% D* a3 w& \: ]+ Y7 ~1 t5 {/ y: h  a9 I/ x# c1 V" r
Complete!
- C4 Q9 {+ c5 L1 d[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all7 i6 e: ^, q2 M5 U) d$ C; w
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
, v6 \4 Z: l, |) W5 h; cCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
8 e8 k* C( h% w, \) ?will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting + z' P/ \! D  U& f  f5 C
deprecation_warnings=False in ansible.cfg./ R  ^  t) S. c; u" K
/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.5 P0 O5 a) ~$ s3 @! y' Q% @
  from cryptography.exceptions import InvalidSignature  D8 E% `. U4 f' o/ O5 r( D
192.168.13.165 | CHANGED | rc=0 >>
* Z- w( I. ?% k  o) L% Gtotal 20. f2 h7 c8 t% _! c* ~8 F
dr-xr-xr-x.  17 root root  244 Feb 10 21:00 .
5 t$ w7 x" J% H4 f9 hdr-xr-xr-x.  17 root root  244 Feb 10 21:00 ..9 ~" M' d  s% r6 g8 D, D% ?
-rw-r--r--    1 root root    0 Feb 10 21:00 .autorelabel
6 p, {5 N$ C5 I7 ilrwxrwxrwx.   1 root root    7 Jun 22  2021 bin -> usr/bin8 Q9 G8 j8 P; W9 W* o1 v
dr-xr-xr-x.   5 root root 4096 Apr 18  2022 boot
% L6 X: @: S6 |# v. wdrwxr-xr-x   20 root root 3180 Feb 11 09:29 dev/ h: I7 t( b! I5 l  w- U$ I" S
drwxr-xr-x.  85 root root 8192 Feb 11 11:38 etc: Y* h! V! _% |& G
drwxr-xr-x.   2 root root    6 Jun 22  2021 home
# p9 ~5 e& e' K9 I# ~3 qlrwxrwxrwx.   1 root root    7 Jun 22  2021 lib -> usr/lib
1 }7 ~' J/ t' \# w6 s: w( D3 k0 Qlrwxrwxrwx.   1 root root    9 Jun 22  2021 lib64 -> usr/lib64* S* G+ X# b! y; F. [# A0 B- t
drwxr-xr-x.   2 root root    6 Jun 22  2021 media) O8 X5 t' \! H8 ?# f( L
drwxr-xr-x.   3 root root   18 Apr 18  2022 mnt
. H$ Y0 w2 q; e0 m1 A" Jdrwxr-xr-x.   2 root root    6 Jun 22  2021 opt4 C$ M0 L% X- I; d
dr-xr-xr-x  171 root root    0 Feb 11 09:29 proc
+ U8 d* C$ |( `/ V) l  Pdr-xr-x---.   5 root root  210 Feb 11 11:35 root
9 O3 e$ p, ?) X7 z* v; ?drwxr-xr-x   27 root root  780 Feb 11 11:10 run
" I- _3 I! E; Z, vlrwxrwxrwx.   1 root root    8 Jun 22  2021 sbin -> usr/sbin
; N4 m8 D4 q8 B) x- q! Zdrwxr-xr-x.   2 root root    6 Jun 22  2021 srv
8 O3 p2 m2 a; i& _: m* ?dr-xr-xr-x   13 root root    0 Feb 11 09:29 sys
) J/ }( \9 t$ V$ m$ b9 o  R" Odrwxrwxrwt.  15 root root 4096 Feb 11 11:38 tmp1 g( E, v) c% l3 A+ g+ W7 y) y1 I0 O6 y6 v
drwxr-xr-x.  12 root root  144 Apr 18  2022 usr/ R  Q; R1 X* ^6 q/ ~3 V
drwxr-xr-x.  20 root root  278 May 19  2022 var' z- F) {& t1 p9 F

* L# G1 E% y& R1 ]% E
: z7 V% Y1 c) i* c; H" {2 o2 \5 Z

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 11:45:17 | 显示全部楼层
[root@controller ~]# ansible -i inventory -m ping contol
( m, U) m7 Q4 }6 y: _: ^4 w[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. ) u1 h7 t8 E) L/ t. w8 v
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 , K& ~2 y1 s" Z, r7 P3 c  l
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting 7 Z! v% p, J" z) Z
deprecation_warnings=False in ansible.cfg.
7 i& [6 q$ O% W/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.# }' u& `+ |& v0 w# ~# Q" j
  from cryptography.exceptions import InvalidSignature# h) z( C0 Q" L0 k$ ]
192.168.13.165 | SUCCESS => {5 d/ G' u5 i' I2 ]$ S* N
    "ansible_facts": {
' \. \: }; r& Y/ H        "discovered_interpreter_python": "/usr/libexec/platform-python"- @6 \% N7 A6 o! B" f4 B. t4 l
    },
/ R: W) G7 _1 x; P" Z) o! `    "changed": false,8 _: C: F8 d1 X# e; R) X' ]
    "ping": "pong"3 I7 w  H8 E: Y
}3 C8 s  q  K% H2 W) B" b

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 16:15:43 | 显示全部楼层
什么情况会出现要求安装sshpass:
: Y% ]( ~8 ]. H# c/ A! K7 P5 \. o, E
  如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说( ?- |1 d( d. q+ B, h
" q% N* Z' j& L. R/ ~
  1、在运行ansible的主机上要与被控机建立ssh信任。
8 H, b: A" ^5 _4 V& `& `& v* U! \+ N4 q% f7 R
  2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 02:05 , Processed in 0.027320 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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