Documentation ¶
Index ¶
- Variables
- 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 Dial(proto string, c *Config) (*ssh.Client, error)
- func GetSigner(prvFile string, passphrase string) (ssh.Signer, error)
- func HasAgent() bool
- func KnownHosts(file string) (ssh.HostKeyCallback, error)
- type Auth
- type Client
- func (c Client) Close() error
- func (c Client) Command(name string, args ...string) (*Cmd, error)
- func (c Client) Download(remotePath string, localPath string) (err error)
- func (c Client) NewSftp(opts ...sftp.ClientOption) (*sftp.Client, error)
- func (c Client) Run(cmd string) ([]byte, error)
- func (c Client) Upload(localPath string, remotePath string) (err error)
- type Cmd
- type Config
Constants ¶
This section is empty.
Variables ¶
var DefaultTimeout = 20 * time.Second
DefaultTimeout is the timeout of ssh client connection.
Functions ¶
func AddKnownHost ¶ added in v0.3.0
AddKnownHost add a a host to known hosts file.
func CheckKnownHost ¶ added in v0.3.0
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 ¶ added in v1.1.0
DefaultKnownHostsPath returns default user knows hosts file.
func KnownHosts ¶
func KnownHosts(file string) (ssh.HostKeyCallback, error)
KnownHosts returns host key callback from a custom known hosts path.
Types ¶
type Auth ¶
type Auth []ssh.AuthMethod
Auth represents ssh auth methods.
type Client ¶
Client represents Goph client.
func NewUnknown ¶
NewUnknown starts a ssh connection get client without cheking knownhosts. PLEASE AVOID USING THIS, UNLESS YOU KNOW WHAT ARE YOU DOING! if there a "man in the middle proxy", this can harm you! You can add the key to know hosts and use New() func instead!
type Cmd ¶ added in v0.9.0
type Cmd struct { // Path to command executable filename Path string // Command args. Args []string // Session env vars. Env []string // SSH session. *ssh.Session }
Cmd it's like os/exec.Cmd but for ssh session.
func (*Cmd) CombinedOutput ¶ added in v0.9.0
CombinedOutput runs cmd on the remote host and returns its combined stdout and stderr.