# OpenSSH for a midas node. pasta forwards exactly one port, from the machine's
# WireGuard address only, to port 2222 here; nothing else reaches this container.
# 2222, not 22: a port below 1024 needs CAP_NET_BIND_SERVICE, and the container
# is better off without one more capability than with a conventional number.
#
# Two hooks into midas carry everything midas adds:
#   AuthorizedKeysCommand — the agent key is offered only while the node is leased
#   ForceCommand          — warnings, session logging, then the command as typed
Port 2222
HostKey /work/.ssh-host/ssh_host_ed25519_key
AuthorizedKeysFile none
AuthorizedKeysCommand /usr/local/bin/midas node authorized-keys %u %k
AuthorizedKeysCommandUser build
AllowUsers build
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
ForceCommand /usr/local/bin/midas node session
AcceptEnv LANG LC_*
AllowTcpForwarding no
AllowStreamLocalForwarding no
AllowAgentForwarding no
X11Forwarding no
PermitTunnel no
GatewayPorts no
PermitUserEnvironment no
PrintMotd no
# SFTP (modern scp uses it): `midas node session` sees the subsystem command and
# hands it straight to sftp-server, with no warnings on its binary stream.
Subsystem sftp /usr/lib/ssh/sftp-server
ClientAliveInterval 30
ClientAliveCountMax 6
LogLevel INFO
