SSH server entry point. #77
34
cmd/ssh/README.md
Normal file
34
cmd/ssh/README.md
Normal 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>
|
||||||
|
```
|
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user