sshutils

package
v0.0.0-...-b6284df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateFromPrivateKeyContent

func CreateFromPrivateKeyContent(user string, privateKey []byte, passphrase ...string) (*ssh.ClientConfig, error)

CreateFromPrivateKeyContent create using private key content

func CreateFromPrivateKeyFile

func CreateFromPrivateKeyFile(user string, privateKeyFile string, passfphrase ...string) (*ssh.ClientConfig, error)

CreateFromPrivateKeyFile create using private key from file

func CreateFromUserPassword

func CreateFromUserPassword(user, pwd string) *ssh.ClientConfig

CreateFromUserPassword connect via user password

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client implements an SSH client that supports running commands and scripts remotely.

func Dial

func Dial(addr string, config *ssh.ClientConfig) (*Client, error)

Dial to remote server

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying client network connection.

func (*Client) Cmd

func (c *Client) Cmd(cmd string) (stdout []byte, stderr []byte, err error)

Cmd creates a RemoteScript that can run the command on the client. The cmd string is split on newlines and each line is executed separately.

func (*Client) Download

func (c *Client) Download(remoteFilePath string, localFilePath string) error

Download file from remote server!

func (*Client) UploadFile

func (c *Client) UploadFile(localFilePath, remoteFilePath string) error

UploadFile upload file to remote via ftp

type SSHtunnel

type SSHtunnel struct {
	Local  *connectionEndpoint
	Server *connectionEndpoint
	Remote *connectionEndpoint

	Config *ssh.ClientConfig
	// contains filtered or unexported fields
}

SSHtunnel define local remote server and remote resource to use

func CreateTunnel

func CreateTunnel(localPort int, resourceHost string, resourcePort int, intermediateServerHost string, intermediateServerPort int, sshConf *ssh.ClientConfig) (*SSHtunnel, error)

CreateTunnel a tunnel via an intermediateServer

func (*SSHtunnel) Close

func (tunnel *SSHtunnel) Close()

Close the tunnel and release any resources

func (*SSHtunnel) Start

func (tunnel *SSHtunnel) Start() error

Start listening to incomming connectiopn on local host and forward them to the remote tunnel

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL