goph

package
v0.3.32 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UDP string = "udp"
	TCP string = "tcp"
)

Variables

This section is empty.

Functions

func Conn

func Conn(c *Client, cfg *ssh.ClientConfig) (err error)

Set new net connection to a client.

func DefaultKnownHosts

func DefaultKnownHosts() (ssh.HostKeyCallback, error)

Use default known hosts files to verify host public key.

func Download

func Download(c *ssh.Client, src string, dest string) (err error)

Download remote file to local.

func GetSigner

func GetSigner(prvFile string, passphrase string) (ssh.Signer, error)

Get private key signer.

func KnownHosts

func KnownHosts(kh string) (ssh.HostKeyCallback, error)

Get known hosts callback from a custom path.

func Upload

func Upload(c *ssh.Client, src string, dest string) (err error)

Upload local file to remote.

Types

type Auth

type Auth []ssh.AuthMethod

func Key

func Key(prvFile string, passphrase string) Auth

Get auth method from private key with or without passphrase.

func Password

func Password(pass string) Auth

Get auth method from raw password.

type Client

type Client struct {
	Port  int
	Auth  Auth
	Addr  string
	User  string
	Conn  *ssh.Client
	Proto string
}

func New

func New(user string, addr string, auth Auth) (c *Client, err error)

Connect to ssh and get client, the host public key must be in known hosts.

func NewConn

func NewConn(user string, addr string, auth Auth, callback ssh.HostKeyCallback) (c *Client, err error)

Get new client connection.

func NewUnknown

func NewUnknown(user string, addr string, auth Auth) (*Client, error)

Connect to ssh and 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!

func (Client) Close

func (c Client) Close() error

Close client net connection.

func (Client) Download

func (c Client) Download(remotePath string, localPath string) error

Download file from remote machine!

func (Client) NewSession

func (c Client) NewSession() (*ssh.Session, error)

Get new ssh session from client connection See: https://pkg.go.dev/golang.org/x/crypto/ssh?tab=doc#Session

func (Client) Run

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

Run a command over ssh connection

func (Client) Upload

func (c Client) Upload(localPath string, remotePath string) error

Upload a local file to remote machine!

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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