MCPcopy
hub / github.com/runfinch/finch / NewClientConfig

Function NewClientConfig

pkg/fssh/fssh.go:50–67  ·  view source on GitHub ↗

NewClientConfig returns a client config that can only connect to a loopback address.

(fs afero.Fs, user string, privateKeyPath string)

Source from the content-addressed store, hash-verified

48
49// NewClientConfig returns a client config that can only connect to a loopback address.
50func NewClientConfig(fs afero.Fs, user string, privateKeyPath string) (*ssh.ClientConfig, error) {
51 fileBytes, err := afero.ReadFile(fs, privateKeyPath)
52 if err != nil {
53 return nil, fmt.Errorf("failed to open private key file: %w", err)
54 }
55 signer, err := ssh.ParsePrivateKey(fileBytes)
56 if err != nil {
57 return nil, fmt.Errorf("failed to parse private key from %s: %w", privateKeyPath, err)
58 }
59
60 auths := []ssh.AuthMethod{ssh.PublicKeys(signer)}
61
62 return &ssh.ClientConfig{
63 User: user,
64 Auth: auths,
65 HostKeyCallback: hostKeyCallback(),
66 }, nil
67}

Callers 2

ApplyMethod · 0.92
TestNewClientConfigFunction · 0.85

Calls 2

hostKeyCallbackFunction · 0.85
ErrorfMethod · 0.65

Tested by 1

TestNewClientConfigFunction · 0.68