MCPcopy Index your code
hub / github.com/appleboy/easyssh-proxy / getKeyFile

Function getKeyFile

easyssh.go:118–137  ·  view source on GitHub ↗

returns ssh.Signer from user you running app home path + cutted key path. (ex. pubkey,err := getKeyFile("/.ssh/id_rsa") )

(keypath, passphrase string)

Source from the content-addressed store, hash-verified

116// returns ssh.Signer from user you running app home path + cutted key path.
117// (ex. pubkey,err := getKeyFile("/.ssh/id_rsa") )
118func getKeyFile(keypath, passphrase string) (ssh.Signer, error) {
119 var pubkey ssh.Signer
120 var err error
121 buf, err := os.ReadFile(keypath)
122 if err != nil {
123 return nil, err
124 }
125
126 if passphrase != "" {
127 pubkey, err = sshkeys.ParseEncryptedPrivateKey(buf, []byte(passphrase))
128 } else {
129 pubkey, err = ssh.ParsePrivateKey(buf)
130 }
131
132 if err != nil {
133 return nil, err
134 }
135
136 return pubkey, nil
137}
138
139// returns *ssh.ClientConfig and io.Closer.
140// if io.Closer is not nil, io.Closer.Close() should be called when

Callers 2

getSSHConfigFunction · 0.85
TestGetKeyFileFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGetKeyFileFunction · 0.68