agent refactoring - create agent/docker.go, agent/system.go

This commit is contained in:
Henry Dollman
2024-09-28 17:49:04 -04:00
parent 2ecf5572ba
commit 73d0dd25ec
6 changed files with 416 additions and 395 deletions

View File

@@ -8,13 +8,13 @@ import (
sshServer "github.com/gliderlabs/ssh"
)
func (a *Agent) startServer() {
func (a *Agent) startServer(pubKey []byte, addr string) {
sshServer.Handle(a.handleSession)
slog.Info("Starting SSH server", "address", a.addr)
if err := sshServer.ListenAndServe(a.addr, nil, sshServer.NoPty(),
slog.Info("Starting SSH server", "address", addr)
if err := sshServer.ListenAndServe(addr, nil, sshServer.NoPty(),
sshServer.PublicKeyAuth(func(ctx sshServer.Context, key sshServer.PublicKey) bool {
allowed, _, _, _, _ := sshServer.ParseAuthorizedKey(a.pubKey)
allowed, _, _, _, _ := sshServer.ParseAuthorizedKey(pubKey)
return sshServer.KeysEqual(key, allowed)
}),
); err != nil {