Back to godoc.org
github.com/appleboy/easyssh-proxy

Package easyssh

v1.3.7
Latest Go to latest

The highest tagged major version is .

Published: May 24, 2020 | License: MIT | Module: github.com/appleboy/easyssh-proxy

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 DefaultConfig struct {
	User              string
	Server            string
	Key               string
	KeyPath           string
	Port              string
	Passphrase        string
	Password          string
	Timeout           time.Duration
	Ciphers           []string
	KeyExchanges      []string
	Fingerprint       string
	UseInsecureCipher bool
}

DefaultConfig for ssh proxy config

type MakeConfig

type MakeConfig struct {
	User              string
	Server            string
	Key               string
	KeyPath           string
	Port              string
	Passphrase        string
	Password          string
	Timeout           time.Duration
	Proxy             DefaultConfig
	Ciphers           []string
	KeyExchanges      []string
	Fingerprint       string
	UseInsecureCipher bool
}

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, *ssh.Client, 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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier