Add ssh instructions, log host key

This commit is contained in:
lash 2024-09-22 16:09:57 +01:00
parent 9b71244391
commit e4c3e9f015
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 38 additions and 0 deletions

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 ( import (
"context" "context"
"encoding/hex" "encoding/hex"
"encoding/base64"
"errors" "errors"
"fmt" "fmt"
"net" "net"
@ -222,6 +223,9 @@ func(s *SshRunner) Run(ctx context.Context, keyStore *SshKeyStore) {
if err != nil { if err != nil {
logg.ErrorCtxf(ctx, "Failed to parse private key", "err", err) 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) cfg.AddHostKey(private)
s.lst, err = net.Listen("tcp", fmt.Sprintf("%s:%d", s.Host, s.Port)) s.lst, err = net.Listen("tcp", fmt.Sprintf("%s:%d", s.Host, s.Port))