move agent socket dial to client connection creation

This commit is contained in:
William Banfield
2022-11-30 18:02:16 -05:00
parent 1a2afa62c5
commit 9c8c6c4cff
2 changed files with 8 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
package ssh
import (
"net"
"os"
"path/filepath"
@@ -23,7 +24,12 @@ func Exec(cfg *ssh.ClientConfig, addr, cmd string) error {
return nil
}
func NewClientConfig(ac agent.ExtendedAgent) (*ssh.ClientConfig, error) {
func NewClientConfig() (*ssh.ClientConfig, error) {
c, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK"))
if err != nil {
return nil, err
}
ac := agent.NewClient(c)
hkc, err := knownhosts.New(filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts"))
if err != nil {
return nil, err

View File

@@ -5,12 +5,10 @@ import (
"errors"
"fmt"
"math/rand"
"net"
"os"
"strconv"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/agent"
"github.com/tendermint/tendermint/libs/log"
e2e "github.com/tendermint/tendermint/test/e2e/pkg"
@@ -95,12 +93,7 @@ func NewCLI() *CLI {
case "docker":
cli.infp = &docker.Provider{Testnet: testnet}
case "digital-ocean":
c, err := net.Dial("unix", os.Getenv("SSH_AUTH_SOCK")) // TODO(williambanfield): Ensure this is a consistent location for the authentication socket of the agent.
if err != nil {
return err
}
ac := agent.NewClient(c)
cfg, err := e2essh.NewClientConfig(ac)
cfg, err := e2essh.NewClientConfig()
if err != nil {
return err
}