Given the hostname of a server, I want to get its Host/Public key (stored in /etc/ssh/) using JavaScript in the browser.
I am aware that in the command line, we can get a host key using the ssh-keyscan utility. I want to do the same thing using JS (preferably vanilla JS).
A Node.js script could probably do it a few different ways.
ssh-keyscan command a human would use, via the built-in child_process moduleYou would capture the content of stdout and stderr as strings, and then parse those strings manually.
file module to read the file contents as a string, which you would then parse manuallyBoth of those will work using vanilla JS, and would not require that you install any third-party modules.
Note that Node might need special permissions. You might not encounter that difficulty running this on your local workstation, as yourself, but in a security-conscious environment it will probably require special steps.