Skip to content

Regression on known_hosts fingerprints management #41653

@tomlaredo

Description

@tomlaredo

Description

Probably linked to #40005 and #40878

With Salt server and minion in version 2016.11.5, I experiment many problems with managing known_hosts fingerprints.

The code I provide was working some months ago (sorry for the imprecision, not sure about the version and time).

Error messages

Here are the errors I run into:

[WARNING ] Public Key hashing currently defaults to "md5". This will change to "sha256" in the Nitrogen release.
[ERROR   ] Remote host public key found but its fingerprint does not match one you have provided

Resulting in final message like this:

----------
          ID: known-hosts-server210
    Function: ssh_known_hosts.present
        Name: server210.rodacom.net
      Result: False
     Comment: Remote host public key found but its fingerprint does not match one you have provided
     Started: 17:12:28.007827
    Duration: 376.707 ms
     Changes:   

Setup

{% set allgrains = salt['mine.get']('*', 'grains.items') %}
{% for servname, servconf in pillar.servers|dictsort %}
{% if servconf.domain == grains.domain %}
{% set servfqdn = servname + '.' + servconf.domain %}
{% set fingerprint = allgrains.get(servfqdn, {}).get('ssh_fingerprint', '') %}
{% if fingerprint %}
known-hosts-{{ servname }}:
    ssh_known_hosts.present:
        - name: {{ servfqdn }}
        - user: intercom
        - fingerprint: {{ fingerprint }}
        - fingerprint_hash_type: sha256
        - unless:
            - ssh-keygen -H -f /srv/intercom/.ssh/known_hosts -F {{ servfqdn }}
{% endif %}
{% endif %}
{% endfor %}

Metadata

Metadata

Assignees

No one assigned

    Labels

    PlatformRelates to OS, containers, platform-based utilities like FS, system based appsState-Modulebugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions