diff --git a/cmd/ssh/README.md b/cmd/ssh/README.md new file mode 100644 index 0000000..071557b --- /dev/null +++ b/cmd/ssh/README.md @@ -0,0 +1,34 @@ +# URDT-USSD SSH server + +An SSH server entry point for the vise engine. + + +## Adding public keys for access + +Map your (client) public key to a session identifier (e.g. phone number) + +``` +go run -v -tags logtrace ./cmd/ssh/sshkey/main.go -i [--dbdir ] +``` + + +## Create a private key for the server + +``` +ssh-keygen -N "" -f +``` + + +## Run the server + + +``` +go run -v -tags logtrace ./cmd/ssh/main.go -h -p [--dbdir ] +``` + + +## Connect to the server + +``` +ssh -T -p +``` diff --git a/internal/ssh/ssh.go b/internal/ssh/ssh.go index 31cbc3e..394f55f 100644 --- a/internal/ssh/ssh.go +++ b/internal/ssh/ssh.go @@ -3,6 +3,7 @@ package ssh import ( "context" "encoding/hex" + "encoding/base64" "errors" "fmt" "net" @@ -222,6 +223,9 @@ func(s *SshRunner) Run(ctx context.Context, keyStore *SshKeyStore) { if err != nil { logg.ErrorCtxf(ctx, "Failed to parse private key", "err", err) } + srvPub := private.PublicKey() + srvPubStr := base64.StdEncoding.EncodeToString(srvPub.Marshal()) + logg.InfoCtxf(ctx, "have server key", "type", srvPub.Type(), "public", srvPubStr) cfg.AddHostKey(private) s.lst, err = net.Listen("tcp", fmt.Sprintf("%s:%d", s.Host, s.Port))