MCPcopy Create free account
hub / github.com/libgit2/git2go / NewCredentialSSHKey

Function NewCredentialSSHKey

credentials.go:171–190  ·  view source on GitHub ↗

NewCredentialSSHKey creates new ssh credentials reading the public and private keys from the file system.

(username string, publicKeyPath string, privateKeyPath string, passphrase string)

Source from the content-addressed store, hash-verified

169// NewCredentialSSHKey creates new ssh credentials reading the public and private keys
170// from the file system.
171func NewCredentialSSHKey(username string, publicKeyPath string, privateKeyPath string, passphrase string) (*Credential, error) {
172 runtime.LockOSThread()
173 defer runtime.UnlockOSThread()
174
175 cred := newCredential()
176 cusername := C.CString(username)
177 defer C.free(unsafe.Pointer(cusername))
178 cpublickey := C.CString(publicKeyPath)
179 defer C.free(unsafe.Pointer(cpublickey))
180 cprivatekey := C.CString(privateKeyPath)
181 defer C.free(unsafe.Pointer(cprivatekey))
182 cpassphrase := C.CString(passphrase)
183 defer C.free(unsafe.Pointer(cpassphrase))
184 ret := C.git_credential_ssh_key_new(&cred.ptr, cusername, cpublickey, cprivatekey, cpassphrase)
185 if ret != 0 {
186 cred.Free()
187 return nil, MakeGitError(ret)
188 }
189 return cred, nil
190}
191
192// NewCredentialSSHKeyFromMemory creates new ssh credentials using the publicKey and privateKey
193// arguments as the values for the public and private keys.

Callers 1

NewCredSshKeyFunction · 0.85

Calls 4

newCredentialFunction · 0.85
MakeGitErrorFunction · 0.85
freeMethod · 0.80
FreeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…