Where the ssh server fingerprint file is stored on the OpenWRT router

Currently I am doing a lot of tweaking and modification with the OpenWRT firmware and I am using the Offline Image Generator.
That said after re-flashing my router with the new firmware for the first ssh-ing into the re-flashed router I have to change the knownhosts file in windows and replace the old server fingerprint with a new one.

Since I guess it everytime with generating a new image a new fingerprint is also issued and included within the image.

I am wondering if I could get the location of that ssh-server fingerprint file on the router and replace it with my own custom one during image creation, so I do not need to modify my windows knownhosts file with logging into my re-flash router for the first time.

Kindly tell me where I could find the server ssh-finger print file on the OpenWRT router, for following cases:

[-1-] dropbear as the ssh-server
[-2-] openssh-server pkg installed on the router

In addition, how can I solve this issue if I would like to use password-less ssh and using public key instead?

I would like to generate the key files prior to include them inside the router image.
Thanks

The fingerprint is a hash of the public key. It is not saved in the host. The host key is in /etc/dropbear/dropbear_ed25519_host_key. There may also be an RSA host key, but use of RSA keys is deprecated.

Password-less (pubkey) login is achieved by placing the public part of the client's key in /etc/dropbear/authorized_keys. The client will then access its matching locally stored private key either by default or with the -i option on the client.

4 Likes

Incorrect. The key is randomly generated on first boot - either upon an initial flashing or a reset to defaults. It is not in the image.

1 Like

You could copy that host key(s) from your live router, and include it as a custom file to your next image.