Documentation
¶
Overview ¶
Package sshagent is lys-secrets' SSH agent: it serves the agent protocol for the keys in ~/.ssh that have a .pub beside them and for those added with ssh-add. An encrypted key's passphrase is asked through the desktop's dialog on its first signature, and may be remembered in the login collection, so that signing needs no prompt while it is unlocked. Decrypted keys live in locked memory and are dropped when the login collection locks.
Index ¶
- Constants
- type Agent
- func (a *Agent) Add(key agent.AddedKey) error
- func (a *Agent) Close()
- func (a *Agent) Extension(string, []byte) ([]byte, error)
- func (a *Agent) Forget()
- func (a *Agent) List() ([]*agent.Key, error)
- func (a *Agent) Lock(passphrase []byte) error
- func (a *Agent) Remove(key ssh.PublicKey) error
- func (a *Agent) RemoveAll() error
- func (a *Agent) Serve(ctx context.Context, ln *usersock.Listener)
- func (a *Agent) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error)
- func (a *Agent) SignWithFlags(key ssh.PublicKey, data []byte, flags agent.SignatureFlags) (*ssh.Signature, error)
- func (a *Agent) Signers() ([]ssh.Signer, error)
- func (a *Agent) Unlock(passphrase []byte) error
- type Key
- type Passphrases
- type Prompter
Constants ¶
const Schema = "dev.stubbe.lys.SshKey"
Schema is the xdg:schema of a remembered passphrase's item in the login collection; its other attributes are the key's fingerprint and path.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is the agent's keys.
func New ¶
func New(dir string, prompter Prompter, passphrases Passphrases) *Agent
New is an agent for the keys in dir (~/.ssh), asking prompter and remembering passphrases in passphrases.
func (*Agent) Forget ¶
func (a *Agent) Forget()
Forget drops every decrypted key of ~/.ssh, as the login collection locking does; the next signature asks again or reads the remembered passphrase.
func (*Agent) List ¶
List is the keys of ~/.ssh, then those added with ssh-add; none while the agent is locked.
func (*Agent) Remove ¶
Remove drops an added key; a key of ~/.ssh stays listed, its decrypted copy dropped.
func (*Agent) SignWithFlags ¶
func (a *Agent) SignWithFlags(key ssh.PublicKey, data []byte, flags agent.SignatureFlags) (*ssh.Signature, error)
SignWithFlags signs data with key, an RSA key with the SHA-2 algorithm flags ask for.
type Key ¶
type Key struct {
// Path is the private key's file, "" for a key added with ssh-add.
Path string
Fingerprint string
Comment string
}
Key is a key as the dialogs name it.
type Passphrases ¶
type Passphrases interface {
Lookup(attrs map[string]string) (passphrase []byte, found bool, err error)
Remember(label string, attrs map[string]string, passphrase []byte) error
}
Passphrases keeps remembered passphrases in the login collection. A locked login collection is an error.
type Prompter ¶
type Prompter interface {
// KeyPassphrase asks for an encrypted key's passphrase and whether to
// remember it; ok is false when they dismissed the dialog. retry says
// the previous attempt was wrong.
KeyPassphrase(ctx context.Context, k Key, retry bool) (passphrase []byte, remember, ok bool, err error)
// ConfirmUse asks whether a key added with ssh-add -c may sign.
ConfirmUse(ctx context.Context, k Key) (bool, error)
}
Prompter asks the user about keys.