There are plenty of answers to questions similar to this one but I can't seem to find one with a clear answer. They all either grab the public key at least once, ignore the key altogether, or write directly to the known_hosts file (implies no hash)
I have the server's fingerprint and/or public key. I would like a shell command to add it to the client's
known_hosts file. This has to use whatever is configured (hash/no-hash)
Also, the script will do a git pull from this server so I don't know if providing port information at this point is relevant or not. Please tell me if it is.
Thanks. And feel free to point me in the right direction if this has already been answered and I missed it somehow.
PS - Extra info: One of the reasons I ask about ports is because I've done the following to no success (I'm aware this is getting the key from the host which I would rather not do):
ssh-keygen -R my.awesome.host # hostname ssh-keygen -R 22.214.171.124 # IP ssh-keygen -R my.awesome.host,126.96.36.199 ssh-keyscan -H my.awesome.host,188.8.131.52 >> ~/.ssh/known_hosts ssh-keyscan -H 184.108.40.206 >> ~/.ssh/known_hosts ssh-keyscan -H my.awesome.host >> ~/.ssh/known_hosts
But when I git clone (via ssh) I'm met with a resounding:
The authenticity of host '[my.awesome.host]:7999 ([220.127.116.11]:7999)' can't be established. RSA key fingerprint is fi:ger:pr:in:ti:nf:or:ma:ti:on Are you sure you want to continue connecting (yes/no)?
ssh email@example.com does not prompt me about the fingerprint.