π I'm trying to do something straightforward with Dagger and failing miserably! I'm trying to run sshd as a service, here's the code I'm using:
package main
import (
"dagger/rde/internal/dagger"
"fmt"
)
type Rde struct{}
func (m *Rde) SSH(
// Optionally override the username
// +optional
// +default="dagger"
username string,
) *dagger.Container {
return dag.Container().
From("ubuntu:latest").
WithExposedPort(2222, dagger.ContainerWithExposedPortOpts{Protocol: dagger.Tcp}).
WithExec([]string{"apt-get", "update"}).
WithExec([]string{"apt-get", "install", "-y", "openssh-server"}).
WithExec([]string{"mkdir", "-p", "/var/run/sshd"}).
WithExec([]string{"useradd", "-m", "-d", "/home/" + username, "-s", "/bin/bash", username}).
WithExec([]string{"/bin/bash", "-c", fmt.Sprintf("echo \"%s:%s\" | chpasswd", username, username)}).
WithExec([]string{"sed", "-i", `s/#PermitRootLogin/PermitRootLogin/`, "/etc/ssh/sshd_config"}).
WithExec([]string{"sed", "-i", `s/#PasswordAuthentication yes/PasswordAuthentication yes/`, "/etc/ssh/sshd_config"}).
WithExec([]string{"sed", "-i", `s/#PermitEmptyPasswords no/PermitEmptyPasswords yes/`, "/etc/ssh/sshd_config"}).
WithEntrypoint([]string{"/usr/sbin/sshd", "-D", "-p", "2222"})
}

and in case you hit anything like this in the future, if you run at