forked from tg123/sshpiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (39 loc) · 1.11 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:build full || e2e
package main
import (
log "github.com/sirupsen/logrus"
"github.com/tg123/sshpiper/libplugin"
"github.com/urfave/cli/v2"
)
func main() {
libplugin.CreateAndRunPluginTemplate(&libplugin.PluginTemplate{
Name: "fixed",
Usage: "sshpiperd fixed plugin, only password auth is supported",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "target",
Usage: "target ssh endpoint address",
EnvVars: []string{"SSHPIPERD_FIXED_TARGET"},
Required: true,
},
},
CreateConfig: func(c *cli.Context) (*libplugin.SshPiperPluginConfig, error) {
target := c.String("target")
host, port, err := libplugin.SplitHostPortForSSH(target)
if err != nil {
return nil, err
}
return &libplugin.SshPiperPluginConfig{
PasswordCallback: func(conn libplugin.ConnMetadata, password []byte) (*libplugin.Upstream, error) {
log.Info("routing to ", target)
return &libplugin.Upstream{
Host: host,
Port: int32(port),
IgnoreHostKey: true,
Auth: libplugin.CreatePasswordAuth(password),
}, nil
},
}, nil
},
})
}