GetSigner returns a signer that has a key with the given comment.
(comment string, opts ...AgentOption)
| 177 | |
| 178 | // GetSigner returns a signer that has a key with the given comment. |
| 179 | func (a *Agent) GetSigner(comment string, opts ...AgentOption) (ssh.Signer, error) { |
| 180 | key, err := a.GetKey(comment, opts...) |
| 181 | if err != nil { |
| 182 | return nil, err |
| 183 | } |
| 184 | |
| 185 | signers, err := a.Signers() |
| 186 | if err != nil { |
| 187 | return nil, errors.Wrap(err, "error listing signers") |
| 188 | } |
| 189 | |
| 190 | keyBytes := key.Marshal() |
| 191 | for _, sig := range signers { |
| 192 | if bytes.Equal(keyBytes, sig.PublicKey().Marshal()) { |
| 193 | return sig, nil |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | return nil, ErrNotFound |
| 198 | } |
| 199 | |
| 200 | // RemoveKeys removes the keys with the given comment from the agent. |
| 201 | func (a *Agent) RemoveKeys(comment string, opts ...AgentOption) (bool, error) { |