Documentation ¶
Overview ¶
Package easyssh provides a simple implementation of some SSH protocol features in Go. You can simply run a command on a remote server or get a file even simpler than native console SSH client. You don't need to think about Dials, sessions, defers, or public keys... Let easyssh think about it!
Index ¶
- type DefaultConfig
- type MakeConfig
- func (ssh_conf *MakeConfig) Connect() (*ssh.Session, error)
- func (ssh_conf *MakeConfig) Run(command string, timeout ...time.Duration) (outStr string, errStr string, isTimeout bool, err error)
- func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error
- func (ssh_conf *MakeConfig) Stream(command string, timeout ...time.Duration) (<-chan string, <-chan string, <-chan bool, <-chan error, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultConfig ¶
type DefaultConfig struct { User string Server string Key string KeyPath string Port string Password string Timeout time.Duration }
DefaultConfig for ssh proxy config
type MakeConfig ¶
type MakeConfig struct { User string Server string Key string KeyPath string Port string Password string Timeout time.Duration Proxy DefaultConfig }
MakeConfig Contains main authority information. User field should be a name of user on remote server (ex. john in ssh john@example.com). Server field should be a remote machine address (ex. example.com in ssh john@example.com) Key is a path to private key on your local machine. Port is SSH server port on remote machine. 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)
func (*MakeConfig) Connect ¶
func (ssh_conf *MakeConfig) Connect() (*ssh.Session, error)
Connect to remote server using MakeConfig struct and returns *ssh.Session
func (*MakeConfig) Run ¶
func (ssh_conf *MakeConfig) Run(command string, timeout ...time.Duration) (outStr string, errStr string, isTimeout bool, err error)
Run command on remote machine and returns its stdout as a string
func (*MakeConfig) Scp ¶
func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error
Scp uploads sourceFile to remote machine like native scp console app.
func (*MakeConfig) Stream ¶
func (ssh_conf *MakeConfig) Stream(command string, timeout ...time.Duration) (<-chan string, <-chan string, <-chan bool, <-chan error, error)
Stream returns one channel that combines the stdout and stderr of the command as it is run on the remote machine, and another that sends true when the command is done. The sessions and channels will then be closed.