#!/usr/bin/env ssm # OpenSSH server. # # sshd is run in foreground (-D) so ssm can track the process directly. # Host keys are created if they're missing; sshd refuses to start # without them, so do it before service_command is spawned. service_respawn = on-failure service_command = /usr/sbin/sshd -D -f /etc/ssh/sshd_config service_ready_timeout = 10 pre_start() { if [[ ! -f /etc/ssh/ssh_host_rsa_key ]]; then ssh-keygen -A fi } # Wait for sshd to answer on port 22, not just for the parent process # to return. ready() { (exec 3<>/dev/tcp/127.0.0.1/22) 2>/dev/null }