MCPcopy
hub / github.com/smallstep/cli / GetKey

Method GetKey

internal/sshutil/agent.go:159–176  ·  view source on GitHub ↗

GetKey retrieves a key from the agent by the given comment.

(comment string, opts ...AgentOption)

Source from the content-addressed store, hash-verified

157
158// GetKey retrieves a key from the agent by the given comment.
159func (a *Agent) GetKey(comment string, opts ...AgentOption) (*agent.Key, error) {
160 o := newOptions(opts)
161 keys, err := a.List()
162 if err != nil {
163 return nil, errors.Wrap(err, "error listing keys")
164 }
165 for _, key := range keys {
166 if key.Comment == comment {
167 if o.removeExpiredKey != nil && o.removeExpiredKey(a, key) {
168 continue
169 }
170 if o.filterBySignatureKey == nil || o.filterBySignatureKey(key) {
171 return key, nil
172 }
173 }
174 }
175 return nil, ErrNotFound
176}
177
178// GetSigner returns a signer that has a key with the given comment.
179func (a *Agent) GetSigner(comment string, opts ...AgentOption) (ssh.Signer, error) {

Callers 3

GetSignerMethod · 0.95
GetCertificateMethod · 0.80
loginActionFunction · 0.80

Calls 1

newOptionsFunction · 0.85

Tested by

no test coverage detected