MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / newSSHConfig

Function newSSHConfig

utils/ssh.go:95–115  ·  view source on GitHub ↗
(user, keyFile string)

Source from the content-addressed store, hash-verified

93}
94
95func newSSHConfig(user, keyFile string) (*ssh.ClientConfig, error) {
96 keyData, err := os.ReadFile(keyFile)
97 if err != nil {
98 return nil, fmt.Errorf("%w: failed to read private key (%w) — this is usually a file-permission or antivirus issue; "+
99 "delete that file and reconnect, or check that your security software isn't blocking the .thunder folder", ErrKeyUnreadable, err)
100 }
101
102 signer, err := ssh.ParsePrivateKey(keyData)
103 if err != nil {
104 return nil, fmt.Errorf("failed to parse private key: %w", err)
105 }
106
107 return &ssh.ClientConfig{
108 User: user,
109 Auth: []ssh.AuthMethod{
110 ssh.PublicKeys(signer),
111 },
112 HostKeyCallback: ssh.InsecureIgnoreHostKey(),
113 Timeout: 10 * time.Second,
114 }, nil
115}
116
117func RobustSSHConnect(ip, keyFile string, port int, maxWait int) (*SSHClient, error) {
118 return RobustSSHConnectCtx(context.Background(), ip, keyFile, port, maxWait)

Callers 2

TestNewSSHConfigErrorsFunction · 0.85

Calls 1

ReadFileMethod · 0.65

Tested by 1

TestNewSSHConfigErrorsFunction · 0.68