blacknon / go-sshlib

easy ssh library for golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feedback about known hosts check

sagan opened this issue · comments

Hi

Thanking you for creating this great library. It really helps.

I'd like to share some thought about the "server public key check" feature of this library.

Currently, it's skipping known hosts checking by default. When CheckKnownHosts option is set, it checks the server public key against the provided known hosts file, if encountering an error (unknown or unmatched server public key), it DIRECTLY ask user confirmation in current TTY for adding or updating known hosts file.

I'd like to have a third option, that do check the known hosts file, but let the user decide what to do when encountering an error. To do this, there should be an optional HostKeyCallback func(hostname string, remote net.Addr, key ssh.PublicKey) (err error) field in type Connect struct

Use case: this library could be used to develop non-CLI application (E.g. a web app), which normally does not associate with a TTY or even stdin.