SSH server entry point. #77

Merged
lash merged 11 commits from lash/ssh-2 into master 2024-09-26 15:55:51 +02:00
2 changed files with 38 additions and 0 deletions
Showing only changes of commit e4c3e9f015 - Show all commits

34
cmd/ssh/README.md Normal file
View File

@ -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 <session_id> [--dbdir <dbpath>] <publickey_filepath>
```
## Create a private key for the server
```
ssh-keygen -N "" -f <privatekey_filepath>
```
## Run the server
```
go run -v -tags logtrace ./cmd/ssh/main.go -h <host> -p <port> [--dbdir <dbpath>] <privatekey_filepath>
```
## Connect to the server
```
ssh -T -p <port> <host>
```

View File

@ -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))