易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 553|回复: 2
收起左侧

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

[复制链接]
发表于 2023-2-11 11:39:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all
& G4 p  i2 g0 m& k. M4 z( n[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
$ K/ Z- u+ ]2 ^* yCurrent 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 j- g7 ?9 E6 i# |6 Q" P3 s1 Awill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
6 K4 @! L* I' _7 v( ?6 X, @deprecation_warnings=False in ansible.cfg.
) k+ y# |7 b5 {6 r/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.- h1 j! E. o4 k2 e/ W8 E( d/ D  t
  from cryptography.exceptions import InvalidSignature9 y6 Z* L$ b* F, _, U3 E8 u
[WARNING]: Unhandled error in Python interpreter discovery for host 192.168.13.165: to use the 'ssh' connection5 K+ Q/ `. E* D( k: ]
type with passwords, you must install the sshpass program
% y9 c% Z, T1 p( {0 [% I9 \192.168.13.165 | FAILED | rc=-1 >>
2 E; G+ W) k' ato use the 'ssh' connection type with passwords, you must install the sshpass program4 v5 n; u' c# G
[root@controller ~]# dnf install -y sshpass
) p5 i  p" k# Z5 r+ Q% oLast metadata expiration check: 0:36:36 ago on Sat 11 Feb 2023 11:01:32 AM CST.6 M9 i8 |: J/ x2 i( X& S6 N
Dependencies resolved.
: y* L; {2 Q" W6 \==================================================================================================================
6 ~" U# q8 V$ T3 z Package                  Architecture            Version                        Repository                  Size+ d" ]; W$ |+ j. B
==================================================================================================================
8 W; D2 ^) E+ ~6 uInstalling:
1 Z; S  m( i# K( v( G2 t, h$ N sshpass                  x86_64                  1.09-4.el8                     appstream                   30 k
9 m5 e+ _3 A& f3 z" H1 L1 e$ n0 g* k9 L% b% r
Transaction Summary
+ K1 i. m; R( n: c3 R/ V3 ~==================================================================================================================3 T" U2 k  E* B% e! B- k1 h5 X
Install  1 Package
2 D. x5 W% p) w* {1 S- J
" K+ o. @1 n. {5 W3 M/ ?- R* MTotal download size: 30 k
$ F6 \1 G9 |6 I: SInstalled size: 43 k8 S! G7 ^/ ?  _% N: q. B! O! w5 C) Q- q: [
Downloading Packages:6 F$ W' s* Y2 Q( n. x5 }# E- C, J
sshpass-1.09-4.el8.x86_64.rpm                                                      24 kB/s |  30 kB     00:01    7 z1 X1 i* q" @- E
------------------------------------------------------------------------------------------------------------------$ s: c3 A, O, c* j2 x- k& M! ]
Total                                                                              12 kB/s |  30 kB     00:02     ' O; R* s0 G! [
Running transaction check
9 B. S) L' Y) QTransaction check succeeded.3 [7 H3 T5 Q; ^1 s' W0 q8 F0 u
Running transaction test
/ F4 i* \' P0 ^9 O; R  jTransaction test succeeded." _% Q$ l8 o, I3 s8 q/ [1 H8 |6 w
Running transaction
- E! L& D6 Z  C  Preparing        :                                                                                          1/1 8 V5 k/ c/ ?$ m( L# _6 j2 _& `- {) W
  Installing       : sshpass-1.09-4.el8.x86_64                                                                1/1 7 Q: R2 i' S; c: L+ N, r. A
  Running scriptlet: sshpass-1.09-4.el8.x86_64                                                                1/1
! J  C4 D8 ?3 O: w; I  Verifying        : sshpass-1.09-4.el8.x86_64                                                                1/1 1 I: o$ z* c9 G
# ~9 d1 V1 b6 P, K8 q  c1 o
Installed:
- _3 e7 F9 j  _# `7 O# S' r  sshpass-1.09-4.el8.x86_64                                                                                       
9 z: e; r7 @3 g9 J1 `. @* \/ y! ~* P! h- R
Complete!0 W+ _" M, r9 M) w
[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all
7 H4 ]& Q2 \3 b* A[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. # M% z" y0 u) T1 }) q/ o3 D, I
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
5 e) }4 H( H# m. d0 {4 j) p0 Dwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
2 S- X) u$ P+ tdeprecation_warnings=False in ansible.cfg.
3 y" _% d6 K% B+ H/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.
0 ~8 \% _1 t( O0 \7 Y  from cryptography.exceptions import InvalidSignature, R  `3 T9 j" G+ d% t2 @% r1 f
192.168.13.165 | CHANGED | rc=0 >>
  f! K  Q* `/ w( w+ a# N. K  Gtotal 20
+ F' Z% r4 u. H# j* L  hdr-xr-xr-x.  17 root root  244 Feb 10 21:00 .! H$ k# d; K+ |4 _2 F  e1 V
dr-xr-xr-x.  17 root root  244 Feb 10 21:00 ..# J# Z. Q: T; O1 `4 T
-rw-r--r--    1 root root    0 Feb 10 21:00 .autorelabel- ?9 W/ H- f, K$ \, ?  A: V- j8 Q
lrwxrwxrwx.   1 root root    7 Jun 22  2021 bin -> usr/bin
$ Q4 {* c9 B3 ]! Pdr-xr-xr-x.   5 root root 4096 Apr 18  2022 boot) c' s$ H9 p, L* @  [2 s, p3 I! _
drwxr-xr-x   20 root root 3180 Feb 11 09:29 dev7 s2 E- i/ W# E+ e
drwxr-xr-x.  85 root root 8192 Feb 11 11:38 etc
0 F: z5 k4 F- L9 idrwxr-xr-x.   2 root root    6 Jun 22  2021 home7 V' K# G/ c  K0 ~. ]7 o2 C
lrwxrwxrwx.   1 root root    7 Jun 22  2021 lib -> usr/lib
- D- a5 X6 |* @7 Wlrwxrwxrwx.   1 root root    9 Jun 22  2021 lib64 -> usr/lib64
* G, N/ a" H" C. b: ~5 vdrwxr-xr-x.   2 root root    6 Jun 22  2021 media
# I1 R" A+ _  a1 l0 N: udrwxr-xr-x.   3 root root   18 Apr 18  2022 mnt! P5 \" M4 d! G1 ?# ~1 e
drwxr-xr-x.   2 root root    6 Jun 22  2021 opt
' y# s4 ?/ J; e7 Rdr-xr-xr-x  171 root root    0 Feb 11 09:29 proc
. m% o" p8 J* z' M5 V$ Edr-xr-x---.   5 root root  210 Feb 11 11:35 root
) g& h3 P, N/ [drwxr-xr-x   27 root root  780 Feb 11 11:10 run1 j' A4 ]1 X. p) z$ G3 a. w: @% G! Z
lrwxrwxrwx.   1 root root    8 Jun 22  2021 sbin -> usr/sbin
+ V  T' A0 Z: s9 t$ [# z' r0 ^drwxr-xr-x.   2 root root    6 Jun 22  2021 srv; h4 b7 h3 ~7 D! T0 M
dr-xr-xr-x   13 root root    0 Feb 11 09:29 sys1 q& {/ Q, O4 k) }6 N
drwxrwxrwt.  15 root root 4096 Feb 11 11:38 tmp
* O- K' S+ B7 V; a, Ndrwxr-xr-x.  12 root root  144 Apr 18  2022 usr1 X3 L0 q3 H$ k& t
drwxr-xr-x.  20 root root  278 May 19  2022 var9 s- G- |& ~5 _3 g) C" G
2 b/ d/ }9 V9 n+ W0 Q0 x" j
6 }9 y: O1 \1 y1 K  Z* X
 楼主| 发表于 2023-2-11 11:45:17 | 显示全部楼层
[root@controller ~]# ansible -i inventory -m ping contol; D7 P4 P2 m: d2 i) S
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. : e& N! n* ^1 `
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 ' M$ |* T+ h. B! u4 z2 ?, u  n
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting
; N. H: v1 [& i1 j6 L$ kdeprecation_warnings=False in ansible.cfg.
0 Z7 m' u0 t0 D+ X1 U/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.
: Y/ ^3 i4 {! H" |- E  from cryptography.exceptions import InvalidSignature
- x# w* E+ t9 m192.168.13.165 | SUCCESS => {" I$ f2 Q" s0 j5 P1 e
    "ansible_facts": {/ k4 ^) h5 ], l/ \/ L
        "discovered_interpreter_python": "/usr/libexec/platform-python"6 I9 I; `4 d6 e. W7 }9 Z
    },
$ \6 f* z& _7 B& V4 Q# P    "changed": false,; J& K5 t; W: k5 _+ _
    "ping": "pong"5 m% V# I3 ?' e$ L
}
" N( H5 h1 N  {4 Y# N2 c8 p2 u1 T! e
 楼主| 发表于 2023-2-11 16:15:43 | 显示全部楼层
什么情况会出现要求安装sshpass:
4 S: K. [" `" J/ n9 Q4 z" ~; t" b, B) k0 J9 X: i6 H
  如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说4 O% W$ X1 I4 v: D' \6 F* G/ p3 j
  n) T7 Z& a( U. h
  1、在运行ansible的主机上要与被控机建立ssh信任。2 X! c6 u5 e/ S+ `
, P8 B6 e6 u( m5 |! ]- w
  2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 21:37 , Processed in 0.038108 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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