Hi everyone,
I’m trying to start an SSH daemon in Elixir using :ssh.daemon/2,3
, and I want to dynamically generate an SSH host key instead of relying on a pre-existing key file.
I initially tried to do in elixir
# generate keys
{pub, priv} = :crypto.generate_key(:rsa, {2048, 65537})
port = 8989
sftp_dir = Path.join(System.tmp_dir!(), "sftp_dir")
File.mkdir(sftp_dir)
opts = [
{:system_dir, to_charlist("/tmp")},
{:user_passwords, [{~c"user", ~c"password"}]},
{:subsystems, [:ssh_sftpd.subsystem_spec([{:root, to_charlist(sftp_dir)}])]}
]
:ssh.daemon(port, opts)
However, I am unsure how to pass the generated key to :ssh.daemon/2,3
as an option.
- Am I generating the key correctly for use with
:ssh.daemon/2,3
? - How can I pass the generated key to
:ssh.daemon/2,3
so that it does not require a file-based key?
I appreciate any guidance on this!