ssh远程主机秘钥失效的解决方法(ssh黄金参数)

问题描述

在使用秘钥(无密)登录服务器时有如下警告:

Warning: the ECDSA host key for '${hostname}' differs from the key for the IP address '${hostip}'

 

解决方案

方案1: ssh是添加参数 -o UserKnownHostsFile=/dev/null

方案2: ssh-keygen -R ${hostip}

方案3:在ssh配置文件 ~/.ssh/config文件中添加如下配置:

UserKnownHostsFile /dev/null

 

ssh 黄金参数:

ssh -o ConnectTimeout=3 -o ConnectionAttempts=3 -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o ServerAliveInterval=60 -o UserKnownHostsFile=/dev/null $user@$host

ssh配置文件实例:

Host *
User xxx
StrictHostKeyChecking no
CheckHostIP no
ConnectTimeout 3
ConnectionAttempts 3
PasswordAuthentication no
StrictHostKeyChecking no
ServerAliveInterval 60 
UserKnownHostsFile /dev/null

 

 

posted on 2022-11-11 21:12  生活费  阅读(642)  评论(0编辑  收藏  举报

导航