[Wed Apr 30 16:07:06][3735892][oracle@a:~][0]$ ssh host-a
The authenticity of host ‘host-a’ can’t be established.
ECDSA key fingerprint is SHA256:xDaWTCy1NxrqpiMT8djk.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
我们在自动化测试中经常需要链接以前没有链接过的服务器
在自动化脚本中可能会出现这样的提示 导致脚本无法自动运行下去
要想避免这个warning
有以下的方法可以借鉴
第一种方法
在运行ssh链接之前先将远程服务器的fingerprint存到本地的known_hosts里面
ssh-keyscan host-a >> ./.ssh/known_hosts
第二种方法就是在ssh命令添加选项
ssh -o StrictHostkeyChecking=no host-a
第三种方法就是修改配置文件
或者添加到特定用户的配置文件中 .ssh/config/ssh_config文件中
或者添加到全局的配置文件中 /etc/ssh/ssh_config
Host *
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
下面的命令会重新生成服务器端的密钥
ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ‘’