gossh: github.com/uthng/gossh Index | Files

package gossh

import "github.com/uthng/gossh"


Package Files

client.go config.go scp.go


const (
    // SCPFILE file type
    SCPFILE = iota
    // SCPDIR directory type, so recursive
    // SCPGETFILE download a remote file
    // SCPGETDIR download a remote direcotry

type Client Uses

type Client struct {
    // contains filtered or unexported fields

Client encapsulates ssh client

func NewClient Uses

func NewClient(config *Config) (*Client, error)

NewClient initializes a ssh client following authentication configuration

func (*Client) DisableLogColor Uses

func (c *Client) DisableLogColor(level int)

DisableLogColor disables log colors

func (*Client) ExecCommand Uses

func (c *Client) ExecCommand(cmd string) ([]byte, error)

ExecCommand executes a shell command on remote machine

func (*Client) SCPGetDir Uses

func (c *Client) SCPGetDir(srcDir, destDir string) error

SCPGetDir gets srcDir from remote machine and save in destDir. srcDir must be a folder. destDir is the local folder in which all files or subfolders inside srcDir will be stored. If destDir does not exists, it will be created.

func (*Client) SCPGetFile Uses

func (c *Client) SCPGetFile(srcFile, destFile string) error

SCPGetFile gets srcFile from remote machine and save in destDir. srcFile must be a regular file. destFile is the local regular in which srcFile's content will be stored;. If destFile does not exists, it will be created.

func (*Client) SCPSendBytes Uses

func (c *Client) SCPSendBytes(content []byte, destFile, mode string) error

SCPBytes sends content in bytes to remote machine and save it in a file with the given path

func (*Client) SCPSendDir Uses

func (c *Client) SCPSendDir(srcDir, destDir, mode string) error

SCPDir sends recursively a directory to remote machine. Mode is only applied for the 1st directory. All files/folders inside the srcDir will preserve the same mode on remote machine

func (*Client) SCPSendFile Uses

func (c *Client) SCPSendFile(srcFile, destFile, mode string) error

SCPFile sends a file to remote machine

func (*Client) SetVerbosity Uses

func (c *Client) SetVerbosity(level int)

SetVerbosity sets log level

type Config Uses

type Config struct {
    Host         string
    Port         int
    ClientConfig *ssh.ClientConfig

Config englobes ssh client configuration with host/port

func NewClientConfigWithKeyFile Uses

func NewClientConfigWithKeyFile(username string, sshKey string, host string, port int, checkHostKey bool) (*Config, error)

NewClientConfigWithKeyFile returns a configuration corresponding to a simple configuration with private key

func NewClientConfigWithSignedPubKeyFile Uses

func NewClientConfigWithSignedPubKeyFile(username, sshKey, signedPubKey, host string, port int, checkHostKey bool) (*Config, error)

NewClientConfigWithSignedPubKeyFile returns a configuration corresponding to the configuration using private key along with a signed public key.

func NewClientConfigWithUserPass Uses

func NewClientConfigWithUserPass(username string, password string, host string, port int, checkHostKey bool) (*Config, error)

NewClientConfigWithUserPass returns a configuration with given parameters

Package gossh imports 15 packages (graph). Updated 2020-04-23. Refresh now. Tools for package owners.