SSH: Configure ssh_config to use specific key file for a specific server fingerprint

Solution 1:

You can use wildcards in a Host section in ~/.ssh/config. If you use EC2's hostname to connect to your instances the following should work:

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

If you use the IP addresses you'll have to find the right IP ranges and add appropriate wildcard entries to match those.

Solution 2:

Try if this works for you: add to ~/.ssh/config file the following:

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

(comment out the last line if everything else fails)