sshkeyscan

package
v0.0.0-...-ef38420 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sshkeyscan provides the ssh-keyscan utility — retrieve public host keys from remote SSH servers.

It exposes a Config struct with a Parse method for command-line argument parsing, a ScanHostKey function for scanning a single host/key-type pair, and a Run function that orchestrates the full scan.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseKeyTypes

func ParseKeyTypes(spec string) []string

ParseKeyTypes translates user-friendly type names to SSH algorithm names.

func Run

func Run(cfg *Config, streams stdio.Streams) int

Run executes the ssh-keyscan action based on cfg and returns a process exit code.

func ScanHostKey

func ScanHostKey(host string, port int, keyType string, timeout time.Duration) (string, error)

ScanHostKey connects to host:port and retrieves the host key of the specified type. Returns the key in known_hosts format "type base64-key".

Types

type Config

type Config struct {
	AddressFamily string   // "any", "inet", "inet6"
	Hosts         []string // positional host arguments
	HostFile      string   // -f
	Port          int      // -p
	Timeout       int      // -T (seconds)
	KeyTypes      []string // -t
	HashHosts     bool     // -H
	Verbose       bool     // -v
	Version       bool     // -V

	// DialerConfig is populated during Parse and can be adjusted by callers
	// before starting scans.
	DialerConfig dialer.DialConfig
}

Config holds parsed ssh-keyscan command-line arguments.

func (*Config) GetDialer

func (cfg *Config) GetDialer() dialer.Dialer

GetDialer returns the scanner dialer derived from the parsed config.

func (*Config) GetDialerConfig

func (cfg *Config) GetDialerConfig() dialer.DialConfig

GetDialerConfig returns the stored dialer configuration. Parse populates this field, and callers may adjust it before starting any scan.

func (*Config) Parse

func (cfg *Config) Parse(args ...string) error

Parse populates cfg from command-line arguments. Fields set before calling Parse are preserved unless overridden. Default values: Port=22, Timeout=5.

func (*Config) RefreshDialerConfig

func (cfg *Config) RefreshDialerConfig()

RefreshDialerConfig rebuilds DialerConfig from the parsed scanner args.

func (*Config) ScanHostKey

func (cfg *Config) ScanHostKey(host string, keyType string) (string, error)

ScanHostKey retrieves a host key using the scanner's stored dialer config.

Jump to

Keyboard shortcuts

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