chef-ssh icon indicating copy to clipboard operation
chef-ssh copied to clipboard

known_host port format fails for some linux distributions

Open wwoodrow opened this issue 7 years ago • 0 comments

Amazon linux new AMI 2017.09 breaks when using hashed entries with alternate ports, or rather ignores them. As far as I've found the []:port# isn't needed and the known_host file works fine on the few linux distros I've checked without them. The fix that worked for me was to simply strip out the added syntax returned from the call to ssh-keyscan for non-standard ports. This also makes matching easier basically just an added conditional with regex and all was fine:

if new_resource.port == 22 new_resource.key keyscan.stdout.strip else new_resource.key keyscan.stdout.strip.sub(/[(.)].+(ssh.)/, '\1 \2') end

wwoodrow avatar Nov 22 '17 00:11 wwoodrow