Created
June 12, 2014 11:09
-
-
Save maxim/871e611d4bc02c633c67 to your computer and use it in GitHub Desktop.
Adding github to known_hosts with ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: ensure github.com is a known host | |
lineinfile: | |
dest: /root/.ssh/known_hosts | |
create: yes | |
state: present | |
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}" | |
regexp: "^github\\.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice, I couldn't get the known_hosts module to work, but this did!
If you want hashing you can do:
ssh-keyscan -H -t rsa github.com
.To check if you have hashing on you could register:
cat /etc/ssh/ssh_config | grep -q 'HashKnownHosts\s\s*yes'
, then do a whensucceeded
for the hashing.Checking if the lines been added gets trickier if you hash it though...