hostkey

package
v2.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package hostkey implements a callback for the ssh.ClientConfig.HostKeyCallback

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHostKeyMismatch is returned when the host key does not match the host key or a key in known_hosts file.
	ErrHostKeyMismatch = errors.New("host key mismatch")

	// ErrCheckHostKey is returned when the callback could not be created.
	ErrCheckHostKey = errors.New("check hostkey")

	// InsecureIgnoreHostKeyCallback is an insecure HostKeyCallback that accepts any host key.
	InsecureIgnoreHostKeyCallback = ssh.InsecureIgnoreHostKey() //nolint:gosec

	// DefaultKnownHostsPath is the default path to the known_hosts file - make sure to homedir-expand it.
	DefaultKnownHostsPath = "~/.ssh/known_hosts"
)
View Source
var KnownHostsPathFromEnv = func() (string, bool) {
	return os.LookupEnv("SSH_KNOWN_HOSTS")
}

KnownHostsPathFromEnv returns the path to a known_hosts file from the environment variable SSH_KNOWN_HOSTS.

Functions

func KnownHostsFileCallback

func KnownHostsFileCallback(path string, permissive, hash bool) (ssh.HostKeyCallback, error)

KnownHostsFileCallback returns a HostKeyCallback that uses a known hosts file to verify host keys.

func StaticKeyCallback

func StaticKeyCallback(trustedKey string) ssh.HostKeyCallback

StaticKeyCallback returns a HostKeyCallback that checks the host key against a given host key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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