易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 554|回复: 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; o5 Q1 Z7 r4 t- e& m# N8 Z: a& T
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. $ f9 q1 a* O6 d* u7 r; M( w
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 # @, n& ]' |: O6 |: `% X3 @
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting # R9 f7 q9 t$ U8 Y
deprecation_warnings=False in ansible.cfg.+ k7 o! i' M$ X
/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.
) A9 P! w& |- N0 m) \9 N  from cryptography.exceptions import InvalidSignature
, k$ v5 T5 @; o- Y6 j6 U[WARNING]: Unhandled error in Python interpreter discovery for host 192.168.13.165: to use the 'ssh' connection, M# O" Y; U( r) G+ X! z
type with passwords, you must install the sshpass program9 m; R) M4 t1 |" C
192.168.13.165 | FAILED | rc=-1 >>0 h$ S' s' T3 Y; |! c
to use the 'ssh' connection type with passwords, you must install the sshpass program
' b! m: J$ |" q2 {[root@controller ~]# dnf install -y sshpass ( ?' P+ ?3 s" P
Last metadata expiration check: 0:36:36 ago on Sat 11 Feb 2023 11:01:32 AM CST.) e6 T/ y1 Z' E. F
Dependencies resolved.$ L$ ?4 P  g& C# L8 p* Y. f
==================================================================================================================
# }) s8 f% Y! f Package                  Architecture            Version                        Repository                  Size6 Q0 j; x: l! I2 i0 k
==================================================================================================================
# M: U2 ~% J4 r* dInstalling:% m" [# l7 e, e
sshpass                  x86_64                  1.09-4.el8                     appstream                   30 k% T1 w3 E- }7 Q) e" m4 c
% G; S. w+ D2 @$ {
Transaction Summary
; G0 |) `; |- G6 J; n8 O9 z9 |/ j==================================================================================================================
4 k% v7 X! F+ H9 O3 G/ ]Install  1 Package
& N9 X) M. S9 @( Q' O
( C% F6 j& v. e# x- STotal download size: 30 k
( G3 ]' _: _+ `7 `' B8 mInstalled size: 43 k
4 r) ?4 v% b& u% p3 `Downloading Packages:
0 i/ H$ P1 N& ^2 jsshpass-1.09-4.el8.x86_64.rpm                                                      24 kB/s |  30 kB     00:01   
2 k$ `' J; V& y8 s------------------------------------------------------------------------------------------------------------------
7 q1 T/ h9 n- ?. ?' ^. ]7 A+ aTotal                                                                              12 kB/s |  30 kB     00:02     
" `$ e9 H; W0 Z# h/ ?% ~3 JRunning transaction check
8 _& b  b+ |% r+ ?+ K: r- o& s# ETransaction check succeeded.% M, Y. \+ m$ @2 z6 R% R$ t% H( I
Running transaction test0 G  }! S# o' d, e
Transaction test succeeded.- x/ n+ a/ w; o0 |, a- U5 J
Running transaction
, g% g3 ^  i; ^  Preparing        :                                                                                          1/1
  ~- Y0 ?2 y% p  r  Installing       : sshpass-1.09-4.el8.x86_64                                                                1/1 # _# B1 \3 w$ b. _, x+ A) ~
  Running scriptlet: sshpass-1.09-4.el8.x86_64                                                                1/1 & t1 ]4 C2 S6 g* O; p
  Verifying        : sshpass-1.09-4.el8.x86_64                                                                1/1 " J4 e6 E  y# d  M! N

, G. \+ P4 _8 `2 _! [7 n9 P' E. e0 N" K% JInstalled:
/ y: ]8 Q& ~% y2 j( E  sshpass-1.09-4.el8.x86_64                                                                                       
7 I( U: h+ n/ b" w: y6 {+ {/ b  s- A# V( Q+ F
Complete!
( A. z+ L. L3 ~, j, t1 ^[root@controller ~]# ansible -i inventory  -m shell -a 'ls -al /' all
* w4 I6 Y1 r2 u4 c; C[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12. # A1 X) @& K3 ]7 \* b9 E% G
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 1 ?* m5 c  i5 q8 V
will be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting 1 J' }. W( ~5 Y
deprecation_warnings=False in ansible.cfg.( `" ]" ?( k& [' S# w& h8 w( 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.
  L5 z  d. Y8 s  from cryptography.exceptions import InvalidSignature( q4 \( k( N  \( N# a0 E; k
192.168.13.165 | CHANGED | rc=0 >>
5 x2 v- q6 Y4 `- Gtotal 20
; m9 R3 f8 ^: l" L$ ?) tdr-xr-xr-x.  17 root root  244 Feb 10 21:00 .
/ a. L/ K/ D* _. Cdr-xr-xr-x.  17 root root  244 Feb 10 21:00 ..
9 L* L& K6 @) ^! e6 ^3 G-rw-r--r--    1 root root    0 Feb 10 21:00 .autorelabel
) |; @; q4 M! R& l, nlrwxrwxrwx.   1 root root    7 Jun 22  2021 bin -> usr/bin
# m- w& L5 Y& h8 D( q; A( Cdr-xr-xr-x.   5 root root 4096 Apr 18  2022 boot' s: J* o8 y& v* T! i
drwxr-xr-x   20 root root 3180 Feb 11 09:29 dev9 P- ?2 t$ ~$ W  X) N3 A% ?3 l
drwxr-xr-x.  85 root root 8192 Feb 11 11:38 etc
/ r3 d% J! t0 Z5 A& {drwxr-xr-x.   2 root root    6 Jun 22  2021 home
0 M& c; b. N5 H3 v+ u# Xlrwxrwxrwx.   1 root root    7 Jun 22  2021 lib -> usr/lib: M: H& ?( C# L
lrwxrwxrwx.   1 root root    9 Jun 22  2021 lib64 -> usr/lib64
! X# U* x( f9 D' sdrwxr-xr-x.   2 root root    6 Jun 22  2021 media
; ]5 o* |, C! ^% P7 j) Rdrwxr-xr-x.   3 root root   18 Apr 18  2022 mnt
( p/ V2 {, w! H+ }1 zdrwxr-xr-x.   2 root root    6 Jun 22  2021 opt
# ~! r" [. I: N% Ldr-xr-xr-x  171 root root    0 Feb 11 09:29 proc
' ^. |6 T) B( |0 u: @dr-xr-x---.   5 root root  210 Feb 11 11:35 root* A. f2 P! f- }! ]4 ^! L" [" h6 }
drwxr-xr-x   27 root root  780 Feb 11 11:10 run& w  t5 O6 r1 g3 c, `+ P
lrwxrwxrwx.   1 root root    8 Jun 22  2021 sbin -> usr/sbin
. A* ]% M0 U$ m) Rdrwxr-xr-x.   2 root root    6 Jun 22  2021 srv6 C  b* X. I8 p# U- Y
dr-xr-xr-x   13 root root    0 Feb 11 09:29 sys
$ X* |( Q- P0 c2 _5 }drwxrwxrwt.  15 root root 4096 Feb 11 11:38 tmp' {" k# Q7 s: @2 x$ \6 U* N
drwxr-xr-x.  12 root root  144 Apr 18  2022 usr
7 E! \2 n. [" c1 Udrwxr-xr-x.  20 root root  278 May 19  2022 var
% y. P0 V0 [. ^2 h4 Y! j! V) e! _3 X
& y2 u3 C3 `/ m% s
 楼主| 发表于 2023-2-11 11:45:17 | 显示全部楼层
[root@controller ~]# ansible -i inventory -m ping contol/ D- |: L$ C2 Z" S% O
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with Ansible 2.12.
. V+ R" G9 e4 b5 D" ^9 VCurrent version: 3.6.8 (default, Mar 25 2022, 11:15:52) [GCC 8.5.0 20210514 (Red Hat 8.5.0-10)]. This feature
7 n" L# Z# U8 N5 m4 O" |& Nwill be removed from ansible-core in version 2.12. Deprecation warnings can be disabled by setting ( e! }; I% f, O6 b" `# ]( k
deprecation_warnings=False in ansible.cfg.
, Y1 j& X6 S' 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.
& j7 q; H) {3 O! W/ K2 i  from cryptography.exceptions import InvalidSignature
9 y1 v" ]1 ~8 R% c% T192.168.13.165 | SUCCESS => {
6 Q7 B- X4 [/ e. e6 t    "ansible_facts": {( t! e: g6 @; ~. `3 M% ?
        "discovered_interpreter_python": "/usr/libexec/platform-python"9 ?% H9 R& b7 R, x
    },
) L$ L4 J/ G; \+ X. q. V$ p1 `: c    "changed": false,
: i7 G, g5 K$ y: }# Q2 I* S7 f! o    "ping": "pong"3 A3 q9 F, U% W4 o7 _1 V9 \. A
}9 S$ @1 ~, Z1 v  ?5 H/ R3 M+ W
 楼主| 发表于 2023-2-11 16:15:43 | 显示全部楼层
什么情况会出现要求安装sshpass:
  E4 Y  x  u4 w. r, d) X6 V7 s3 i5 e- \" }$ m5 Q7 T  r( x
  如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说
, B" n0 _3 t( S
( X- `7 v3 @% o4 i4 U  1、在运行ansible的主机上要与被控机建立ssh信任。
& \5 F: p' z! M+ o: z; {) y5 @9 x; t5 w. C/ w7 i1 n
  2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 23:59 , Processed in 0.070681 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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