找回密码
 注册
查看: 558|回复: 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
6 K$ m5 y: i5 Z! l2 p[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. ( o4 Y: z: n, l) ?; S' I9 t! d' }
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
4 z# e0 ]( K( ?$ B* ?/ J% N0 Qwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting 6 L: I; l# _. v; G' Z
deprecation_warnings=False in ansible.cfg.
  r& U8 ^2 c( d* a/ m  V, w7 f3 Z% c/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.8 \: O# F2 @# B
  from cryptography.exceptions import InvalidSignature% t) ]" K2 [+ }
[WARNING]: Unhandled error in Python interpreter discovery for host 192.168.13.165: to use the 'ssh' connection1 b) ~4 D# R3 ~4 s
type with passwords, you must install the sshpass program
/ H9 ?4 n4 _2 v' r* U/ ^192.168.13.165 | FAILED | rc=-1 >>. ]) L8 J) a1 F5 j% x6 x3 M7 n4 P
to use the 'ssh' connection type with passwords, you must install the sshpass program' M3 A# ?: Y8 f# ~3 n' G& M1 C6 j
[root@controller ~]# dnf install -y sshpass
/ W7 g& @" {: S6 XLast metadata expiration check: 0:36:36 ago on Sat 11 Feb 2023 11:01:32 AM CST.
7 S  [* L3 c; V; W: R+ e7 NDependencies resolved.8 ^% b8 Q8 m. p. D4 y5 K. c, d1 Z
==================================================================================================================
6 F! s" z4 {5 S$ X8 c2 H  o1 _ Package                  Architecture            Version                        Repository                  Size8 N  o. |+ B, e! Y
==================================================================================================================/ Y! R; A0 f9 e# s* h% Y$ V
Installing:" f' Q( ~! m& W* y* [5 u
sshpass                  x86_64                  1.09-4.el8                     appstream                   30 k
2 m: L# e" n, [3 @2 K! b8 v. k) i( \. U+ A# W& C
Transaction Summary+ ?+ ?* P: O* q  A: f, i" D
==================================================================================================================% n2 Z8 S1 c" [
Install  1 Package8 Q$ t9 Q- i- }$ i4 J- S; \. n8 ]

* A5 k6 l' Q9 u/ Q$ }, ?  UTotal download size: 30 k
! Z/ X9 P) B" p$ VInstalled size: 43 k
2 c7 A% w. K* O7 q6 j* nDownloading Packages:
: G* u3 P5 Z/ Msshpass-1.09-4.el8.x86_64.rpm                                                      24 kB/s |  30 kB     00:01   
+ L, R! |" N; L* W1 g$ R------------------------------------------------------------------------------------------------------------------4 c, k% h! }2 `* w
Total                                                                              12 kB/s |  30 kB     00:02     
( Q3 I) @$ j0 m  |Running transaction check
0 v3 o2 D8 }. L1 U6 _Transaction check succeeded.
' @2 b5 u% w9 n4 M/ [# \8 @& b1 fRunning transaction test) m5 i" }) A  o5 g: ^7 i
Transaction test succeeded., J. C) l0 K. \5 W6 o* i& r% W1 p" N/ q
Running transaction
; i+ y9 G8 E9 B* l0 g$ v  Preparing        :                                                                                          1/1 , V( @1 Z. f. V# S
  Installing       : sshpass-1.09-4.el8.x86_64                                                                1/1 % y* b4 Z8 Z* o! E7 w
  Running scriptlet: sshpass-1.09-4.el8.x86_64                                                                1/1
6 y# @" [% [5 [+ i" P  Verifying        : sshpass-1.09-4.el8.x86_64                                                                1/1
5 s& ~8 p  g+ Y4 g( t: x- y% ^5 i+ \% ~# d0 A) O$ {; E- f1 b  V
Installed:% G- ?. [# O$ E0 `4 }  }% u
  sshpass-1.09-4.el8.x86_64                                                                                       1 w1 }% S! V2 ~' b! ?; z5 Z

; C( N$ M- S5 RComplete!
- b; f" o5 i+ i9 @, u- X8 j[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all
. M! K2 u' f# f9 ?% |[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
2 ^; m$ P8 ]) fCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
2 m+ Z* j: S* r: p; `! x: l% D; Gwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting * n% L. s- D+ B) N/ I. Q2 P
deprecation_warnings=False in ansible.cfg.
+ g2 R4 E9 K% \- ^$ E/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 q/ H3 w- D9 A) }) h) _
  from cryptography.exceptions import InvalidSignature
! p6 a* x$ K$ y. _192.168.13.165 | CHANGED | rc=0 >>1 X8 [$ M2 H2 l) A( F
total 20
) J. m- \( ]  C/ I! a1 jdr-xr-xr-x.  17 root root  244 Feb 10 21:00 .2 {7 h1 G! |2 v% B; I, x
dr-xr-xr-x.  17 root root  244 Feb 10 21:00 ..0 _& A$ J/ ?; ]9 F, m
-rw-r--r--    1 root root    0 Feb 10 21:00 .autorelabel
2 h1 J/ ~; w% }# Ylrwxrwxrwx.   1 root root    7 Jun 22  2021 bin -> usr/bin3 k- o( I/ y1 E' O% ?, n9 ]* p
dr-xr-xr-x.   5 root root 4096 Apr 18  2022 boot
4 i5 Z, j- v; H  v. p! ~$ k* v" Q3 ydrwxr-xr-x   20 root root 3180 Feb 11 09:29 dev) y* L& p; n- I0 R0 y4 L9 ?" H
drwxr-xr-x.  85 root root 8192 Feb 11 11:38 etc6 f5 t( e- |% D6 Y/ q8 s
drwxr-xr-x.   2 root root    6 Jun 22  2021 home
' F" o& k) |% @- e( G1 J7 hlrwxrwxrwx.   1 root root    7 Jun 22  2021 lib -> usr/lib$ s- Y! D; b1 [: k
lrwxrwxrwx.   1 root root    9 Jun 22  2021 lib64 -> usr/lib64
" o" N. S6 n  i( K- gdrwxr-xr-x.   2 root root    6 Jun 22  2021 media! z* _- n) U( ~9 q, k$ y
drwxr-xr-x.   3 root root   18 Apr 18  2022 mnt2 q8 H1 \1 T) e' a9 ]
drwxr-xr-x.   2 root root    6 Jun 22  2021 opt( [, k) }+ S& [$ {4 k
dr-xr-xr-x  171 root root    0 Feb 11 09:29 proc9 k6 j2 b- a, X6 o' y
dr-xr-x---.   5 root root  210 Feb 11 11:35 root9 S6 R* q! q7 K- ^, y
drwxr-xr-x   27 root root  780 Feb 11 11:10 run
. A- `3 `9 a) {$ u# olrwxrwxrwx.   1 root root    8 Jun 22  2021 sbin -> usr/sbin
; H: E) W9 J+ p3 Mdrwxr-xr-x.   2 root root    6 Jun 22  2021 srv
9 G* k/ v9 I8 v! p1 ^) D9 {0 Udr-xr-xr-x   13 root root    0 Feb 11 09:29 sys
& L9 g- U0 w7 E* C1 o1 gdrwxrwxrwt.  15 root root 4096 Feb 11 11:38 tmp( t( K) j. J% i# w
drwxr-xr-x.  12 root root  144 Apr 18  2022 usr
6 Z& I3 W$ E6 Q0 z1 p0 a4 Q7 Hdrwxr-xr-x.  20 root root  278 May 19  2022 var5 Q4 ]% U$ f1 H/ F

7 u7 }! Q2 {+ Q# F4 P0 Y$ f
$ z) |  ~; P0 V4 Q

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 11:45:17 | 显示全部楼层
[root@controller ~]# ansible -i inventory -m ping contol8 S. R$ S- P+ q8 _. L! {
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. ! z* e; ~! u( a8 H! ^$ `
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 " R( J  ~  [  S- c; \+ b; r
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting 9 N* o" {; j; D9 X6 k
deprecation_warnings=False in ansible.cfg.3 K7 A) N" b6 T, s
/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.9 w. y9 J- Z) `/ U( [' q5 A+ w3 Y
  from cryptography.exceptions import InvalidSignature
. Z; V% v+ b' K+ i  E4 M8 e3 W192.168.13.165 | SUCCESS => {0 L3 ^. ]7 k$ n$ g0 _
    "ansible_facts": {$ m) Y7 F4 c# d6 B- R
        "discovered_interpreter_python": "/usr/libexec/platform-python"
! ~) g9 |7 {$ f8 P    },5 n( u9 `. m' X) l7 q4 ]
    "changed": false,
' w3 t) T5 o$ ?# y9 `    "ping": "pong"" m) [+ ?- [1 ^( K& J% I
}6 A, L! O9 w+ p3 m, \$ M5 R2 H

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 16:15:43 | 显示全部楼层
什么情况会出现要求安装sshpass:7 B1 X7 w7 v0 s& C
/ I$ K5 B; n8 }; m
  如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说2 M0 ^5 C6 b. e* h/ L" Y

' M! o7 s4 W/ E  1、在运行ansible的主机上要与被控机建立ssh信任。' S5 x0 J* u/ E1 G7 {2 F. e' W
( g; D5 B  J+ q# ]
  2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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