fleet: github.com/dongsupark/fleet/ssh Index | Files

package ssh

import "github.com/dongsupark/fleet/ssh"

Index

Package Files

known_hosts.go match.go proxy.go ssh.go

Constants

const (
    DefaultKnownHostsFile = "~/.fleetctl/known_hosts"
)

Variables

var (
    ErrUntrustHost = errors.New("unauthorized host")
    ErrUnmatchKey  = errors.New("host key mismatch")
)

func DialCommand Uses

func DialCommand(client *SSHForwardingClient, cmd string) (net.Conn, error)

func Execute Uses

func Execute(client *SSHForwardingClient, cmd string) (error, int)

Execute runs the given command on the given client with stdin/stdout/stderr connected to the controlling terminal. It returns any error encountered in the SSH session, and the exit status of the remote command.

func SSHAgentClient Uses

func SSHAgentClient() (gosshagent.Agent, error)

SSHAgentClient returns an Agent that talks to the local ssh-agent

func Shell Uses

func Shell(client *SSHForwardingClient) error

Shell launches an interactive shell on the given client. It returns any error encountered in setting up the SSH session.

type HostKeyChecker Uses

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

HostKeyChecker implements the gossh.HostKeyChecker interface It is used for key validation during the cryptographic handshake

func NewHostKeyChecker Uses

func NewHostKeyChecker(m HostKeyManager) *HostKeyChecker

NewHostKeyChecker returns a new HostKeyChecker

func (*HostKeyChecker) Check Uses

func (kc *HostKeyChecker) Check(addr string, remote net.Addr, key gossh.PublicKey) error

Check is called during the handshake to check the server's public key for unexpected changes. The key argument is in SSH wire format. It can be parsed using ssh.ParsePublicKey. The address before DNS resolution is passed in the addr argument, so the key can also be checked against the hostname. It returns any error encountered while checking the public key. A nil return value indicates that the key was either successfully verified (against an existing known_hosts entry), or accepted by the user as a new key.

func (*HostKeyChecker) GetHostKeyAlgorithms Uses

func (kc *HostKeyChecker) GetHostKeyAlgorithms(addr string) []string

Returns public key algorithms of the remote host that are listed inside known_hosts

type HostKeyFile Uses

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

HostKeyFile is an implementation of HostKeyManager that saves and loads "known hosts" keys from a file

func NewHostKeyFile Uses

func NewHostKeyFile(path string) *HostKeyFile

NewHostKeyFile returns a new HostKeyFile using the given file path

func (*HostKeyFile) GetHostKeys Uses

func (f *HostKeyFile) GetHostKeys() (map[string][]gossh.PublicKey, error)

func (*HostKeyFile) PutHostKey Uses

func (f *HostKeyFile) PutHostKey(addr string, hostKey gossh.PublicKey) error

func (*HostKeyFile) String Uses

func (f *HostKeyFile) String() string

type HostKeyManager Uses

type HostKeyManager interface {
    String() string
    // GetHostKeys returns a map from host patterns to a list of PublicKeys
    GetHostKeys() (map[string][]gossh.PublicKey, error)
    // put new host key under management
    PutHostKey(addr string, hostKey gossh.PublicKey) error
}

HostKeyManager defines an interface for managing "known hosts" keys

type SSHForwardingClient Uses

type SSHForwardingClient struct {
    *gossh.Client
    // contains filtered or unexported fields
}

func NewSSHClient Uses

func NewSSHClient(user, addr string, checker *HostKeyChecker, agentForwarding bool, timeout time.Duration) (*SSHForwardingClient, error)

func NewTunnelledSSHClient Uses

func NewTunnelledSSHClient(user, tunaddr, tgtaddr string, checker *HostKeyChecker, agentForwarding bool, timeout time.Duration) (*SSHForwardingClient, error)

func (*SSHForwardingClient) ForwardAgentAuthentication Uses

func (s *SSHForwardingClient) ForwardAgentAuthentication(session *gossh.Session) error

Package ssh imports 17 packages (graph). Updated 2019-10-19. Refresh now. Tools for package owners.