diff --git a/easyssh.go b/easyssh.go index c530eea..60999b9 100644 --- a/easyssh.go +++ b/easyssh.go @@ -27,11 +27,12 @@ import ( // Note: easyssh looking for private key in user's home directory (ex. /home/john + Key). // Then ensure your Key begins from '/' (ex. /.ssh/id_rsa) type MakeConfig struct { - User string - Server string - Key string - Port string - Password string + User string + Server string + Key string + Port string + Password string + InsecureIgnoreHostKey bool } // returns ssh.Signer from user you running app home path + cutted key path. @@ -75,9 +76,19 @@ func (ssh_conf *MakeConfig) connect() (*ssh.Session, error) { auths = append(auths, ssh.PublicKeys(pubkey)) } - config := &ssh.ClientConfig{ - User: ssh_conf.User, - Auth: auths, + var config *ssh.ClientConfig + if ssh_conf.InsecureIgnoreHostKey == true { + config = &ssh.ClientConfig{ + User: ssh_conf.User, + Auth: auths, + HostKeyCallback: ssh.InsecureIgnoreHostKey(), + } + } else { + config = &ssh.ClientConfig{ + User: ssh_conf.User, + Auth: auths, + } + } client, err := ssh.Dial("tcp", ssh_conf.Server+":"+ssh_conf.Port, config)