Documentation ¶
Index ¶
- func AddKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (err error)
- func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (found bool, err error)
- func DefaultKnownHosts() (ssh.HostKeyCallback, error)
- func DefaultKnownHostsPath() (string, error)
- func PasswordKey(username string, password string, timeout int) *ssh.ClientConfig
- func PrivateKey(username string, path string, timeout int) (*ssh.ClientConfig, error)
- func PrivateKeyWithPassphrase(username string, timeout int, passpharase []byte, path string) (*ssh.ClientConfig, error)
- func SSHAgent(username string, timeout int, keyCallBack ssh.HostKeyCallback) (*ssh.ClientConfig, error)
- type SSHClient
- type WriteCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddKnownHost ¶
AddKnownHost add a a host to known hosts file.
func CheckKnownHost ¶
func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (found bool, err error)
CheckKnownHost checks is host in known hosts file. it returns is the host found in known_hosts file and error, if the host found in known_hosts file and error not nil that means public key mismatch, maybe MAN IN THE MIDDLE ATTACK! you should not handshake.
func DefaultKnownHosts ¶
func DefaultKnownHosts() (ssh.HostKeyCallback, error)
DefaultKnownHosts returns host key callback from default known hosts path, and error if any.
func DefaultKnownHostsPath ¶
DefaultKnownHostsPath returns default user knows hosts file.
func PasswordKey ¶
func PasswordKey(username string, password string, timeout int) *ssh.ClientConfig
Creates a configuration for a client that authenticates using username and password
func PrivateKey ¶
PrivateKey Loads a private and public key from "path" and returns a SSH ClientConfig to authenticate with the server
func PrivateKeyWithPassphrase ¶
func PrivateKeyWithPassphrase(username string, timeout int, passpharase []byte, path string) (*ssh.ClientConfig, error)
Creates the configuration for a client that authenticates with a password protected private key
func SSHAgent ¶
func SSHAgent(username string, timeout int, keyCallBack ssh.HostKeyCallback) (*ssh.ClientConfig, error)
Creates a configuration for a client that fetches public-private key from the SSH agent for authentication
Types ¶
type SSHClient ¶
type SSHClient struct { Addr string Config *ssh.ClientConfig *ssh.Client }
SSHClient represents Goph client.
func NewSSHClient ¶
func NewSSHClient(server, port string, config *ssh.ClientConfig) (c *SSHClient)
NewConn returns new client and error if any.
type WriteCounter ¶
type WriteCounter struct {
Total int64 // Total # of bytes written
}