mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-20 23:14:37 +00:00
add client creation logic
This commit is contained in:
+13
-1
@@ -22,12 +22,24 @@ func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClientConfig(key string) (*ssh.ClientConfig, error) {
|
func NewClientConfig(keyFile string) (*ssh.ClientConfig, error) {
|
||||||
hkc, err := knownhosts.New(filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts"))
|
hkc, err := knownhosts.New(filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
key, err := os.ReadFile(keyFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
signer, err := ssh.ParsePrivateKey(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
return &ssh.ClientConfig{
|
return &ssh.ClientConfig{
|
||||||
HostKeyCallback: hkc,
|
HostKeyCallback: hkc,
|
||||||
|
Auth: []ssh.AuthMethod{
|
||||||
|
ssh.PublicKeys(signer),
|
||||||
|
},
|
||||||
|
HostKeyAlgorithms: []string{ssh.KeyAlgoED25519},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-2
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@@ -13,7 +14,9 @@ import (
|
|||||||
"github.com/tendermint/tendermint/libs/log"
|
"github.com/tendermint/tendermint/libs/log"
|
||||||
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
|
||||||
"github.com/tendermint/tendermint/test/e2e/pkg/infra"
|
"github.com/tendermint/tendermint/test/e2e/pkg/infra"
|
||||||
|
"github.com/tendermint/tendermint/test/e2e/pkg/infra/digitalocean"
|
||||||
"github.com/tendermint/tendermint/test/e2e/pkg/infra/docker"
|
"github.com/tendermint/tendermint/test/e2e/pkg/infra/docker"
|
||||||
|
e2essh "github.com/tendermint/tendermint/test/e2e/pkg/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
const randomSeed = 2308084734268
|
const randomSeed = 2308084734268
|
||||||
@@ -85,9 +88,23 @@ func NewCLI() *CLI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cli.testnet = testnet
|
cli.testnet = testnet
|
||||||
cli.infp = &infra.NoopProvider{}
|
switch inft {
|
||||||
if inft == "docker" {
|
case "docker":
|
||||||
cli.infp = &docker.Provider{Testnet: testnet}
|
cli.infp = &docker.Provider{Testnet: testnet}
|
||||||
|
case "digitalocean":
|
||||||
|
|
||||||
|
// TMP: hardcoded key
|
||||||
|
cfg, err := e2essh.NewClientConfig(filepath.Join(os.Getenv("HOME"), ".ssh", "PVT_KEY"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cli.infp = &digitalocean.Provider{
|
||||||
|
Testnet: testnet,
|
||||||
|
InfrastructureData: ifd,
|
||||||
|
SSHConfig: cfg,
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
cli.infp = &infra.NoopProvider{}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user