Documentation ¶
Index ¶
- Variables
- func NewCertSigner(cert *ssh.Certificate, priv interface{}) (ssh.Signer, error)
- func ParseCertificate(in []byte) (*ssh.Certificate, error)
- func ProxyCommand(cmd, user, host, port string) string
- func PublicKey(key ssh.PublicKey) (crypto.PublicKey, error)
- type Agent
- func (a *Agent) AddCertificate(subject string, cert *ssh.Certificate, priv interface{}) error
- func (a *Agent) AuthMethod() ssh.AuthMethod
- func (a *Agent) Close() error
- func (a *Agent) GetKey(comment string, opts ...AgentOption) (*agent.Key, error)
- func (a *Agent) GetSigner(comment string, opts ...AgentOption) (ssh.Signer, error)
- func (a *Agent) HasKeys(opts ...AgentOption) (bool, error)
- func (a *Agent) ListCertificates(opts ...AgentOption) ([]*ssh.Certificate, error)
- func (a *Agent) ListKeys(opts ...AgentOption) ([]*agent.Key, error)
- func (a *Agent) RemoveAllKeys(opts ...AgentOption) (bool, error)
- func (a *Agent) RemoveKeys(comment string, opts ...AgentOption) (bool, error)
- type AgentOption
- type CertificateInspect
- type Shell
- type ShellOption
- type Signature
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is the error returned if a something is not found.
Functions ¶
func NewCertSigner ¶
func NewCertSigner(cert *ssh.Certificate, priv interface{}) (ssh.Signer, error)
NewCertSigner creates a new signer with the given certificate and private key.
func ParseCertificate ¶
func ParseCertificate(in []byte) (*ssh.Certificate, error)
ParseCertificate returns a certificate from the marshaled bytes.
func ProxyCommand ¶
ProxyCommand replaces %%, %h, %p, and %r in the given command.
%% A literal `%`. %h The remote hostname. %p The remote port. %r The remote username.
Types ¶
type Agent ¶
type Agent struct { agent.ExtendedAgent Conn net.Conn }
Agent represents a client to an ssh.Agent.
func DialAgent ¶
DialAgent returns an ssh.Agent client. It uses the SSH_AUTH_SOCK to connect to the agent.
func (*Agent) AddCertificate ¶
func (a *Agent) AddCertificate(subject string, cert *ssh.Certificate, priv interface{}) error
AddCertificate adds the given certificate to the agent.
func (*Agent) AuthMethod ¶
func (a *Agent) AuthMethod() ssh.AuthMethod
AuthMethod returns the ssh.Agent as an ssh.AuthMethod.
func (*Agent) HasKeys ¶
func (a *Agent) HasKeys(opts ...AgentOption) (bool, error)
HasKeys returns if a key filtered with the given options exists.
func (*Agent) ListCertificates ¶
func (a *Agent) ListCertificates(opts ...AgentOption) ([]*ssh.Certificate, error)
ListCertificates returns the list of certificates in the agent.
func (*Agent) ListKeys ¶
func (a *Agent) ListKeys(opts ...AgentOption) ([]*agent.Key, error)
ListKeys returns the list of keys in the agent.
func (*Agent) RemoveAllKeys ¶
func (a *Agent) RemoveAllKeys(opts ...AgentOption) (bool, error)
RemoveAllKeys removes from the agent all the keys matching the given options.
func (*Agent) RemoveKeys ¶
func (a *Agent) RemoveKeys(comment string, opts ...AgentOption) (bool, error)
RemoveKeys removes the keys with the given comment from the agent.
type AgentOption ¶
type AgentOption func(o *options)
AgentOption is the type used for variadic options in Agent methods.
func WithCertsOnly ¶
func WithCertsOnly() AgentOption
WithCertsOnly filters only those keys accompanied by a certificate.
func WithRemoveExpiredCerts ¶
func WithRemoveExpiredCerts(t time.Time) AgentOption
WithRemoveExpiredCerts will remove the expired certificates automatically.
func WithSignatureKey ¶
func WithSignatureKey(keys []ssh.PublicKey) AgentOption
WithSignatureKey filters certificate not signed by the given signing keys.
type CertificateInspect ¶
type CertificateInspect struct { Type string KeyName string KeyID string KeyAlgo string KeyFingerprint string SigningKeyAlgo string SigningKeyFingerprint string Signature Signature Serial uint64 ValidAfter time.Time ValidBefore time.Time Principals []string CriticalOptions map[string]string Extensions map[string]string }
CertificateInspect contains details of an ssh.Certificate in human readable format.
func InspectCertificate ¶
func InspectCertificate(cert *ssh.Certificate) (*CertificateInspect, error)
InspectCertificate returns a CertificateInspect with the properties of the given ssh.Certificate.
func (*CertificateInspect) Validity ¶
func (c *CertificateInspect) Validity() string
Validity returns a human version of the validity of the certificate. It returns the dates using the local time zone to behave as ssh-keygen.
type Shell ¶
type Shell struct {
// contains filtered or unexported fields
}
Shell implements a remote shell to an SSH server using x/crypto/ssh
func NewShell ¶
func NewShell(user, address string, opts ...ShellOption) (*Shell, error)
NewShell initializes a new shell to the given address.
func (*Shell) LocalForward ¶
LocalForward creates a local listener in the bindAddress forwarding the packages to the remote hostAddress.
func (*Shell) RemoteForward ¶
RemoteForward creates a remote listener in the bindAddress and forwards the packages to the local hostAddress.
func (*Shell) RemoteShell ¶
RemoteShell starts a login shell on the remote host.
type ShellOption ¶
ShellOption is the type used to add new options to the shell.
func WithAuthMethod ¶
func WithAuthMethod(am ssh.AuthMethod) ShellOption
WithAuthMethod adds a new ssh.AuthMethod to the shell.
func WithCertificate ¶
func WithCertificate(cert *ssh.Certificate, priv interface{}) ShellOption
WithCertificate adds a signer with the given certificate as an ssh.AuthMethod.
func WithSigner ¶
func WithSigner(signer ssh.Signer) ShellOption
WithSigner adds the given signer as an ssh.AuthMethod.