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

Method GetSSHKey

credentials.go:124–136  ·  view source on GitHub ↗

GetSSHKey returns the SSH-specific key information from the Cred object.

()

Source from the content-addressed store, hash-verified

122
123// GetSSHKey returns the SSH-specific key information from the Cred object.
124func (o *Credential) GetSSHKey() (username, publickey, privatekey, passphrase string, err error) {
125 if o.Type() != CredentialTypeSSHKey && o.Type() != CredentialTypeSSHMemory {
126 err = fmt.Errorf("credential is not an SSH key: %v", o.Type())
127 return
128 }
129
130 sshKeyCredPtr := (*C.git_cred_ssh_key)(unsafe.Pointer(o.ptr))
131 username = C.GoString(sshKeyCredPtr.username)
132 publickey = C.GoString(sshKeyCredPtr.publickey)
133 privatekey = C.GoString(sshKeyCredPtr.privatekey)
134 passphrase = C.GoString(sshKeyCredPtr.passphrase)
135 return
136}
137
138func NewCredentialUsername(username string) (*Credential, error) {
139 runtime.LockOSThread()

Callers 1

Calls 1

TypeMethod · 0.95

Tested by

no test coverage detected