0

I keep a local git repo at a remote host gitserver deployed to my LAN. When I am away from home I have to access that server through the LAN's external IP. (The router does not offer loopback).

At home my LAN DNS resolves gitserver to the LAN address but when I'm away, I put gitserver to my /etc/hosts file as the external IP of the LAN.

This works well enough for me but I get a warning that the external IP is not in the known_hosts file.

I'm trying to add that key using ssh-keyscan

ssh-keyscan -p 4444 -t ecdsa 100.101.102.103

I get a result like :

[100.101.102.103]:4444 ecdsa-sha2-nistp256 <GOBBLEDEEGOOKalphanumericstring>

I want to update my known_hosts file with that key but the known_hosts file expects what I suspect is a hostID key. For example:

|1|SoMeThing=|AnotherThing= ecdsa-sha2-nistp256 = ecdsa-sha2-nistp256 <GOBBLEDEEGOOKalphanumericstring>

How do I find the SoMeThing... part -- the HostID? -- of the known_hosts entry?

  • 1
    Appending output of ssh-keyscan to known_hosts file works for me ssh-keyscan somdomain.com >> ~/.ssh/known_hosts. You might get a conflict if same ip exists more than one time in know_hosts file. – Michael D. Nov 13 '19 at 23:09
1

The |1|b64|b64 format in known_hosts is a hashed hostname; see HashKnownHosts in man 5 ssh_config and -H in man 1 ssh-keygen. Using this format is optional; if you want it, see -H in man 1 ssh-keyscan

Note that if anyone intercepts your first connection from a given machine to what you think is the correct address (your 100.101.102.103) they can supply a fake key and steal and/or alter the data you send and receive on that machine.

  • ssh-keyscan -H -p 2314 -t ecdsa 100.101.102.103 put exactly what I was looking for. Pasted it into the bottom of known_hosts and mission accomplished. – Stephen Boston Nov 14 '19 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.