func getHostKeyCallback(opts Options) (ssh.HostKeyCallback, error) {
	var knownHostsFiles []string
	switch {
	case opts.KnownHostsCallback != nil:
		return opts.KnownHostsCallback, nil
	case opts.KnownHostsString != "":
		hostKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(opts.KnownHostsString))
		if err != nil {
			return nil, err
		}
		return ssh.FixedHostKey(hostKey), nil
	case opts.KnownHostsFile != "":
		found, err := foundFile(opts.KnownHostsFile)
		if err != nil {
			return nil, err
		}
		if found {
			knownHostsFiles = append(knownHostsFiles, opts.KnownHostsFile)
			break
		}
		fallthrough
	case os.Getenv("VFS_SFTP_KNOWN_HOSTS_FILE") != "":
		found, err := foundFile(os.Getenv("VFS_SFTP_KNOWN_HOSTS_FILE"))
		if err != nil {
			return nil, err
		}
		if found {
			knownHostsFiles = append(knownHostsFiles, os.Getenv("VFS_SFTP_KNOWN_HOSTS_FILE"))
			break
		}
		fallthrough
	case os.Getenv("VFS_SFTP_INSECURE_KNOWN_HOSTS") != "":
		return ssh.InsecureIgnoreHostKey(), nil  
	default:
		var err error
		knownHostsFiles, err = findHomeSystemKnownHosts(knownHostsFiles)
		if err != nil {
			return nil, err
		}
	}
	return knownhosts.New(knownHostsFiles...)
}
getHostKeyCallback gets host key callback for all known_hosts files
package sftp
import (
	"fmt"
	"io/ioutil"
	"os"
	"path"
	"runtime"
	"strings"
	"github.com/mitchellh/go-homedir"
	_sftp "github.com/pkg/sftp"
	"golang.org/x/crypto/ssh"
	"golang.org/x/crypto/ssh/knownhosts"
	"github.com/c2fo/vfs/v6"
	"github.com/c2fo/vfs/v6/utils"
)
const systemWideKnownHosts = "/etc/ssh/ssh_known_hosts"
type Options struct {
	Password           string              `json:"password,omitempty"`        
	KeyFilePath        string              `json:"keyFilePath,omitempty"`     
	KeyPassphrase      string              `json:"keyPassphrase,omitempty"`   
	KnownHostsFile     string              `json:"knownHostsFile,omitempty"`  
	KnownHostsString   string              `json:"knownHostsString,omitempty"`
	KeyExchanges       []string            `json:"keyExchanges,omitempty"`
	AutoDisconnect     int                 `json:"autoDisconnect,omitempty"`  
	KnownHostsCallback ssh.HostKeyCallback  
	Retry              vfs.Retry
	MaxRetries         int
	FileBufferSize     int  
}
func getClient(authority utils.Authority, opts Options) (Client, error) {
	authMethods, err := getAuthMethods(opts)
	if err != nil {
		return nil, err
	}
	hostKeyCallback, err := getHostKeyCallback(opts)
	if err != nil {
		return nil, err
	}
	sshConfig := ssh.Config{KeyExchanges: opts.KeyExchanges}
	config := &ssh.ClientConfig{
		User:            authority.User,
		Auth:            authMethods,
		HostKeyCallback: hostKeyCallback,
		Config:          sshConfig,
	}
	host := authority.Host
	if !strings.Contains(host, ":") {
		host = fmt.Sprintf("%s%s", host, ":22")
	}
	sshClient, err := ssh.Dial("tcp", host, config)
	if err != nil {
		return nil, err
	}
	return _sftp.NewClient(sshClient)
}