Configuring Host Keys

Every SSH server requires a set of keys to identify itself with connecting clients.

If you want these to be generated automatically, you do not need to do anything more when using the SshServer-based implementation. The server will generate a key for each type of public key algorithm supported by the API and save the file in the current working directory, which will then be loaded each time the server starts.

If you want more control over the loading of host keys, you should add them to your SshServer before starting it.

SshServer server = new SshServer(2222);

server.addHostKey(SshKeyUtils.getPrivateKey(new File("rsa_hostkey")));	server.addHostKey(SshKeyUtils.getPrivateKey(new File("ed25519_hostkey")));

Support for rsa-sha2-256 and rsa-sha2-512 signing algorithms is automatic. If you add an RSA key, the SHA2 versions will automatically be configured for that key.