Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a key based login for a server. The IP and DNS of the server can change, because it is hosted on Amazon.

Is there a way to configure the ssh client config to use the specific key file for this server only, when the fingerprint of the server matches?

In other words: Normaly servers are matched by IP or DNS in the ssh client config. I want to do this by fingerprint, becaus IP and DNS can change.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.