sshhandler

package
v0.0.0-...-f8ce401 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHostIfMissing

func AddHostIfMissing(host, knownHostFile string) error

AddHostIfMissing adds a host to knownhosts file if needed

func BuildRepoPath

func BuildRepoPath(url *url.URL) (string, error)

BuildRepoPath splits a url path into its components example: https://github.com/owner/project.git will turn into ./github.com/owner/project

func ParsePrivateKey

func ParsePrivateKey(keyPath string) (*ssh2.PublicKeys, error)

ParsePrivateKey reads the private key from given path

func ParseUrl

func ParseUrl(url string) (*url.URL, error)

ParseUrl parses the url Only http(s) and ssh is allowed Tries to parse unknown format to ssh

Types

type KnownHost

type KnownHost struct {
	Hosts []string
	Key   ssh.PublicKey
}

func GetKey

func GetKey(host string, timeout time.Duration) (KnownHost, error)

GetKey asks a host for PublicKeys in a specific order If a key is available the loop is stopped

type KnownHosts

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

func ParseKnownHosts

func ParseKnownHosts(knownHostsFile string) (*KnownHosts, error)

ParseKnownHosts reads the given known_hosts file and parses the entries If the file doesn't exist, it will be created

func (*KnownHosts) AddHost

func (kh *KnownHosts) AddHost(host KnownHost)

Adds an known host entry to the cached entries

func (*KnownHosts) ContainsHost

func (kh *KnownHosts) ContainsHost(host string) bool

ContainsHost searches all known hosts entries for a host if the host is not found the hashed host is searched for

func (*KnownHosts) SaveKnownHosts

func (kh *KnownHosts) SaveKnownHosts() error

Overwrites existing knownhosts file with all cached entries including the newly added once

Jump to

Keyboard shortcuts

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