Bypass known_hosts file for Vagrant boxes

Submitted by kentr on Sun, 03/19/2017 - 12:26

Problem:

As Vagrant boxes are created & destroyed, the entries in ~/.ssh/known_hosts become obsolete, and SSH throws warnings or fails with vagrant ssh, drush operations, etc.

Solution:

Add these lines to ~/.ssh/known_hosts

######################################################
# Vagrant
######################################################

Host 192.168.*.*
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Host local.*.*
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Host *.loc
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null