天地维杰网

人如秋鸿来有信,事若春梦了无痕


  • 首页

  • Redis

  • java

  • linux

  • 日常问题

  • Spring和Springboot

  • Mac相关

  • 中间件

  • 架构

  • python

  • 前端

  • jvm

  • c语言

  • web3

  • 归档

  • 关于

  • 搜索
close

时间: 0001-01-01   |   阅读: 123 字 ~1分钟

ssh远程执行命令出现「Are you sure you want to continue connecting (yes/no)?」解决方法

The authenticity of host '10.4.111.1 (10.4.111.1)' can't be established.
ECDSA key fingerprint is SHA256:S1VBZZWcIFk1B1dfasDFfwgU2LN1f9WX4gynfkivTsGsU.
ECDSA key fingerprint is MD5:eb:9e:4d:ad:e8:f2:fe:f5:a2:ea:15:1b:9a:7d:6d:93.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.4.111.1' (ECDSA) to the list of known hosts.

因为要通过sshpass批量去远程执行命令,所以每一次都弹出这个很麻烦。

解决办法 :

#首先备份 ssh 配置文件
~]# cp /etc/ssh/ssh_config /etc/ssh/ssh_config_bak

将配置文件中的 StrictHostKeyChecking ask改为 StrictHostKeyChecking no,GSSAPIAuthentication yes 改为 GSSAPIAuthentication no。

Host *
        GSSAPIAuthentication no
        StrictHostKeyChecking no

然后再执行批量的sshpass批量命令就虽然会有提示,但是可以正常执行。

~]# sshpass -p NwV7abcdefg  ssh cachecloud@10.4.111.1 "ps -ef | grep redis-server | grep -v 'grep' | awk '{print $9}' | awk -F ':' '{print $2}'"      >> redis-server.txt

Warning: Permanently added '10.4.111.1' (ECDSA) to the list of known hosts.

另外,如果使用sshpass执行命令但没有返回,可以先把ssh执行的部分拿出来单独执行,可以看出具体未执行的原因是什么,比如我这个就是因为提示了The authenticity of host '10.4.111.1 (10.4.111.1)' can't be established.的原因无法继续执行。

参考文档:https://www.cnblogs.com/iHey/p/15203985.html

不与天斗Domino

不与天斗Domino

Programmer & Architect

183 日志
15 分类
224 标签
© 2013 - 2023 天地维杰网 京ICP备13019191号-1
Powered by - Hugo v0.63.2
Theme by - NexT
0%