Add a new host to known_hosts
ssh into a machine, you get prompted for a confirmation of the key fingerprint. This happens only the first time a machine is
sshed into. After that, there will be an entry added in the
~/.ssh/known_hosts file which will be used.
There are two simple ways (both leaves you open to man in the middle attacks) this prompt can be bypassed.
Pass extra parameters to
By setting the
-o, we can bypass the prompt by not checking
ssh -o StrictHostKeyChecking=no username@hostname
ssh-keyscan command to add entries in
ssh-keyscan command can be used to produce entries similar to what
ssh does, which can be piped into
~/.ssh/known_hosts file. After doing this,
ssh command can be used without any modifications or prompt.
ssh-keyscan -H HostnameOrIP >> ~/.ssh/known_hosts