Skip to content

Instantly share code, notes, and snippets.

@jpswade
Created September 3, 2017 10:25
Show Gist options
  • Save jpswade/63bab340c672fb5c6baf5c1fed953eb5 to your computer and use it in GitHub Desktop.
Save jpswade/63bab340c672fb5c6baf5c1fed953eb5 to your computer and use it in GitHub Desktop.
[[ -e ~/.ssh/id_rsa ]] || ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ""
ssh_hosts="github.com bitbucket.org"
for ssh_host in ${ssh_hosts[@]}; do
ssh_host_ips="$(host ${ssh_host} | awk '/has address/ { print $4 }')"
ssh-keygen -R ${ssh_host}
ssh-keyscan -H ${ssh_host} >> ~/.ssh/known_hosts
for ssh_host_ip in ${ssh_host_ips[@]}; do
ssh-keygen -R ${ssh_host_ip}
ssh-keygen -R ${ssh_host},${ssh_host_ip}
ssh-keyscan -H ${ssh_host},${ssh_host_ip} >> ~/.ssh/known_hosts
ssh-keyscan -H ${ssh_host_ip} >> ~/.ssh/known_hosts
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment