How to pass a known fingerprint to SSH (in order to avoid the manual prompt)

Viewed 249

How do I pass a known fingerprint (such as SHA256:BcOkb1S0zuj5A1CDxpOSuD2hnAArV1A3wKY7iOlks) to SSH, so that I don't need to manually answer the prompt?

I tried the following, which does not seem to work:

ssh some-user@my-domain.com <<EOF
SHA256:BcOkb1S0zuj5A1CDxpOSuD2hnAArV1A3wKY7iOlks
EOF
1 Answers

To add to the comment "You could prepare the complete entry and then copy it to the ~/.ssh/known_hosts file.", that preparation would be done using ssh-keyscan:

ssh-keyscan -H 192.168.1.162 
# or
ssh-keyscan my-domain.com

If you have a known fingerprint, you can also double-check it, if is still valid.

Related