Sometimes you might want to access a machine (say, a server) that you own from another machine that you don’t. There are many use-cases of that. One of it can be using a friend’s computer to login to your server. Or what if you need to take help from an acquaintance because something needs to be addressed urgently?
One of the things that comes handy in such cases is to not disable password-based logins entirely. However, when you access a machine over SSH using a terminal, the known_hosts
file gets modified and the fingerprint of your machine (server) gets logged in that file. If you want to avoid it, the following command can help:
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null user@example.com
Of course you need to replace user@example.com
with the correct hostname and server domain/IP address but other than that, this prevents the host key to be added to the known_hosts
file on the machine that was used to access the machine.
Checked on Ubuntu and macOS only!
I have not encountered the need to do this with a Windows machine so I don’t know if it would work or not; but I don’t think it will because
/dev/null
does not exist on Windows. But I don’t know enough about Windows to make a comment.
I don’t even know who would need it. I found the need to do this only a couple of times so far in life too. But just in case you (or I myself) need it, maybe this page would be of use.
Cheers!