ssh

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package ssh implements functionality associated with ssh agent.

Index

Constants

This section is empty.

Variables

View Source
var DefaultKeyOpt = KeyOpt{
	KeyRefreshFilter: func(key *agent.Key) bool {

		return false
	},
	PrivateKeyValiditySec: defaultKeyValiditySec,
	PublicKeyAlgo:         defaultPublicKeyAlgo,
	PrivateKeyLabel:       defaultPrivateKeyLabel,
	CertLabel:             defaultCertLabel,
}

DefaultKeyOpt is the default option of keyAgent.

Functions

func Agent

func Agent() (ag.Agent, net.Conn, error)

Agent gets the running ssh-agent and its connection

func AgentBySocket

func AgentBySocket(socketPath string) (ag.Agent, net.Conn, error)

AgentBySocket returns the ssh-agent and its connection by the socket.

func AgentConn

func AgentConn() (net.Conn, error)

AgentConn returns the connection for ssh agent based on SSH_AUTH_SOCK.

func ChallengeSSHAgent

func ChallengeSSHAgent(a ag.Agent, key ssh.PublicKey) error

ChallengeSSHAgent verifies the given public key using challenge-response authentication.

func CheckSSHAuthSock

func CheckSSHAuthSock() (string, error)

CheckSSHAuthSock checks for presence of ssh agent and if one present, returns the value of SSH_AUTH_SOCK environment variable.

func ListKeys

func ListKeys(agent ag.Agent, filter keyFilter) ([]ag.Key, error)

ListKeys returns all the keys filtered.

Types

type AgentKey

type AgentKey struct {
	// contains filtered or unexported fields
}

AgentKey represents an SSH key pair in ssh-agent. It also stores the CSRs of the key pair.

func NewSSHAgentKey

func NewSSHAgentKey(agent ag.Agent) (*AgentKey, error)

NewSSHAgentKey initializes an SSHAgentKey from the network connection.

func NewSSHAgentKeyWithOpt

func NewSSHAgentKeyWithOpt(agent ag.Agent, opt KeyOpt) (*AgentKey, error)

NewSSHAgentKeyWithOpt initializes an AgentKey from the network connection and the opt.

func (*AgentKey) AddCertsToAgent

func (a *AgentKey) AddCertsToAgent(certs []ssh.PublicKey, comments []string) error

AddCertsToAgent add the certificates to ssh agent.

func (*AgentKey) PublicKey

func (a *AgentKey) PublicKey() ssh.PublicKey

PublicKey returns the public key of the agent key.

type KeyOpt

type KeyOpt struct {
	// keyFilter is the function to determine whether a key is the target key or cert for that handler.
	KeyRefreshFilter      keyFilter
	PrivateKeyValiditySec uint32
	PrivateKeyLabel       string
	CertLabel             string
	PublicKeyAlgo         key.PublicKeyAlgo
}

KeyOpt is the option for AgentKey.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL