Documentation ¶
Overview ¶
Package hostkeys provides public ssh host key scanning capability similar to the ssh-keyscan utility. It complements the golang.org/x/crypto/ssh and golang.org/x/crypto/ssh/knownhosts packages.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultKeyAlgorithms = []string{ ssh.KeyAlgoED25519, ssh.KeyAlgoRSA, }
DefaultKeyAlgorithms is the default set of algorithms that will be attempted by Scan.
Functions ¶
Types ¶
type Entry ¶
Entry is an ssh host key.
func Scan ¶
Scan retrieves a set of public ssh host keys from a remote host.
If key algorithms are provided, only keys using those algorithms will be returned. If no key algorithms are provided, DefaultKeyAlgorithms will be used.
Entries supported by the remote will be returned in the same order as the requested key algorithms.
Example ¶
package main import ( "fmt" "github.com/gentlemanautomaton/hostkeys" ) func main() { keys, err := hostkeys.Scan("github.com") if err != nil { fmt.Println(err) return } fmt.Print(hostkeys.Marshal(keys...)) }
Output:
func (Entry) String ¶
String returns a string representation of the host key that's compatible with the known_hosts file format. The format is defined here: http://man.openbsd.org/sshd.8