Aqui está uma solução para o ssh-keyscan não obedecendo ao ~ / .ssh / config nem tomando nenhuma opção.
$ ssh -o UserKnownHostsFile=junk -o KexAlgorithms=+diffie-hellman-group1-sha1 192.168.1.2
The authenticity of host '192.168.1.2 (192.168.1.2)' can't be established.
RSA key fingerprint is SHA256:iCnx+DQCcb4rAfNEE71mDiFc+ej9X+XBzBd/5/ueDtE.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
root@router:~# ^D
Connection to 192.168.1.2 closed.
$ cut -d' ' -f2- < junk > junk2
$ ssh-keygen -r 192.168.1.2 -f junk2
192.168.1.2 IN SSHFP 1 1 28.....17
192.168.1.2 IN SSHFP 1 2 882....ed1
$ rm -f junk junk2
e
ssh -o UserKnownHostsFile=junk -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=ssh-dss 192.168.1.2
se você quiser forçar o DSA em vez do RSA.
E para os preguiçosos entre nós:
h=192.168.1.2; for t in ssh-rsa ssh-dss ssh-ed25519 ecdsa-sha2-nistp256 ecdsa-sha2-nistp384 ecdsa-sha2-nistp521; do ssh -o CheckHostIp=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=junk -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms="${t}" "${h}" true && cut -d' ' -f2- < junk > junk2 && ssh-keygen -r "${h}" -f junk2; rm -f junk junk2; done
que produz:
Warning: Permanently added '192.168.1.2' (RSA) to the list of known hosts.
192.168.1.2 IN SSHFP 1 1 28...17
192.168.1.2 IN SSHFP 1 2 882...ed1
Warning: Permanently added '192.168.1.2' (DSA) to the list of known hosts.
192.168.1.2 IN SSHFP 2 1 40..3c
192.168.1.2 IN SSHFP 2 2 26f...e6f
Unable to negotiate with 192.168.1.2 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss
...