SSH:configurationssh_config以将特定的密钥文件用于特定的服务器指纹

我有一个基于密钥的服务器login。 服务器的IP和DNS可以更改,因为它托pipe在Amazon上。

有没有一种方法来configurationSSH客户端configuration使用特定的密钥文件只有当这台服务器的指纹匹配?

换句话说:在ssh客户端configuration中,正常服务器与IP或DNS相匹配。 我想通过指纹来做到这一点,因为IP和DNS可以改变。

你可以在~/.ssh/configHost部分使用通配符。 如果您使用EC2的主机名连接到您的实例,以下应该工作:

 Host *.compute-1.amazonaws.com IdentityFile ~/.ssh/id_rsa.aws # If you don't want to verify host fingerprints because they change all the time CheckHostIP no StrictHostKeyChecking no UserKnownHostsFile /dev/null 

如果使用IP地址,则必须find正确的IP范围,并添加适当的通配符条目以匹配这些IP地址范围。

尝试如果这为你工作:添加到~/.ssh/config文件如下:

 Host alias_for_host_you_want_to_connect HostName real_name_for_host_you_want_to_connect CheckHostIP no IdentityFile /path/to/your/keyfile #StrictHostKeyChecking no 

(如果一切都失败了,注释掉最后一行)