Skip to content

Instantly share code, notes, and snippets.

@altif227
Forked from FelikZ/accept_known_hosts.sh
Created November 28, 2018 13:22
Show Gist options
  • Save altif227/ce3c9b2ea46408a00ebf073089cb0c77 to your computer and use it in GitHub Desktop.
Save altif227/ce3c9b2ea46408a00ebf073089cb0c77 to your computer and use it in GitHub Desktop.
Fix known_hosts file "Jenkins Host key verification failed"
#!/bin/bash
for domain in "github.com" "bitbucket.org"; do
echo $domain
sed -i "/$domain/d" ~/.ssh/known_hosts
line=$(ssh-keyscan $domain,`nslookup $domain | awk '/^Address: / { print $2 ; exit }'`)
echo $line >> ~/.ssh/known_hosts
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment