August 2025
Intermediate to advanced
272 pages
6h 14m
English
ssh is not limited to its use as a client. In fact, you can also use it for the other side: listening for remote connections on a server. This is called an SSH daemon. You can use :ssh.daemon/2[198] to start a daemon:
| | iex> Application.ensure_all_started(:ssh) |
| | iex> port = 10222 |
| | iex :ssh.daemon(port, auth_methods: ~c"publickey", system_dir: ~c"tmp/system") |
You’ll need to generate a host key in the system directory specified in the previous snippet. And that’s pretty much it.
Running an SSH daemon from Erlang can be useful for when your system is a minimal Erlang distribution or when you want to expose only some SSH functionality. These are definitely infrequent use cases, but it’s awesome to have all these tools in the standard ...
Read now
Unlock full access