Используйте опцию StrictHostKeyChecking, например:
ssh -oStrictHostKeyChecking=no $h uptimeЭта опция также может быть добавлена в ~/.ssh/config, например:
Host somehost Hostname 10.0.0.1 StrictHostKeyChecking noОбратите внимание, что при изменении ключей хоста вы получите предупреждение, даже при использовании этой опции:
$ ssh -oStrictHostKeyChecking=no somehost uptime@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!Someone could be eavesdropping on you right now (man-in-the-middle attack)!It is also possible that a host key has just been changed.The fingerprint for the RSA key sent by the remote host is31:6f:2a:d5:76:c3:1e:74:f7:73:2f:96:16:12:e0:d8.Please contact your system administrator.Add correct host key in /home/peter/.ssh/known_hosts to get rid of this message.Offending RSA key in /home/peter/.ssh/known_hosts:24 remove with: ssh-keygen -f "/home/peter/.ssh/known_hosts" -R 10.0.0.1Password authentication is disabled to avoid man-in-the-middle attacks.Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.ash: uptime: not foundЕсли ваши хосты не часто переустанавливаются, вы можете сделать это менее безопасным (но более удобным для часто меняющихся ключей хоста) с помощью -oUserKnownHostsFile=/dev/null вариант. При этом отбрасываются все полученные ключи хоста, поэтому предупреждение никогда не будет выдано.
С 18.04 появилась новая возможность: StrictHostKeyChecking=accept-new. Из man 5 ssh_config:
If this flag is set to “accept-new” then ssh will automaticallyadd new host keys to the user known hosts files, but will notpermit connections to hosts with changed host keys. If this flagis set to “no” or “off”, ssh will automatically add new host keysto the user known hosts files and allow connections to hosts withchanged hostkeys to proceed, subject to some restrictions.