chef-cookbooks / ssh_known_hosts

Development repository for Chef Cookbook ssh_known_hosts
https://supermarket.chef.io/cookbooks/ssh_known_hosts
Apache License 2.0
72 stars 77 forks source link

ssh-keyscan -H issue #31

Closed erkolson closed 9 years ago

erkolson commented 10 years ago

Using CentOS 6.3, the -H option creates a unique hash for the hostname each time it is run. Consequently, each time chef-client runs, it appends another line to /etc/ssh/ssh_known_hosts. The key_exists? method never returns true. Is this the intended behavior?

kevwilde commented 10 years ago

This seems also true on Debian and Ubuntu.

After investigating the issue, it seems that it either searches for the comment or the hash. Given that the hash is never the same for a single host (salted?), only the comment would remain a viable option to check.

However, providers/entry.rb only appends the key to the file and not the comment. Perhaps this can be easily resolved by also appending the comment to the known_hosts file.