ssh/known_hosts: No such file or directory

Viewed 15859
1 Answers

apparently I don't even have that file in the first place. Is there a way to create it?

It will be created for you on your first ssh call

ssh -T git@gitlab.com

That iwll trigger a message like:

The authenticity of host '111.222.333.444 (111.222.333.444)' can't be established.
RSA key fingerprint is f1:cf:58:ae:71:0b:c8:04:6f:34:a6:b2:e4:1e:0c:8b.
Are you sure you want to continue connecting (yes/no)? 

Answering yes will create the ~/.ssh/known_hosts


As chepner says in the comments, you should get the server actual fingerprint ahead of times, before answering 'yes', and comparing that fingerprint to what is added to the ~/.ssh/known_hosts.

See for instance "Securely add a host (e.g. GitHub) to the SSH known_hosts file".

For instance: github.com does give its server fingerprints: compare it with ssh-keyscan -t rsa github.com | ssh-keygen -lf -.

C:\Users\vonc\git>ssh-keyscan -t rsa github.com | ssh-keygen -lf -
# github.com:22 SSH-2.0-babeld-4cec2db4
2048 SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 github.com (RSA)

If it matches, then add it to your ~/.ssh/known_hosts.

Related