ssh

package
v0.0.0-...-96b04c8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakePrivateKeySigner

func MakePrivateKeySigner(privateKey []byte, passPhrase []byte) (ssh.Signer, error)

func MakePrivateKeySignerFromFile

func MakePrivateKeySignerFromFile(key string) (ssh.Signer, error)

func ParsePublicKeyFromFile

func ParsePublicKeyFromFile(keyFile string) (*rsa.PublicKey, error)

Types

type Config

type Config struct {
	User        string `validate:"required"`
	Host        string `validate:"required"`
	Port        int    `validate:"required"`
	Password    string
	PrivateKey  []byte
	PassPhrase  []byte
	DialTimeOut time.Duration
	Retry       int
}

type Interface

type Interface interface {
	Ping() error
	Exec(cmd ...string) (stdout string, stderr string, exit int, err error)
	Run(cmd ...string) error
	CombinedOutput(cmd ...string) ([]byte, error)
	CopyFile(src, dst string) error
	WriteFile(src io.Reader, dst string) error
	ReadFile(filename string) ([]byte, error)
	Stat(p string) (os.FileInfo, error)
	LookPath(file string) (string, error)
}

type SSH

type SSH struct {
	User string
	Host string
	Port int

	Retry int
	// contains filtered or unexported fields
}

func New

func New(c *Config) (*SSH, error)

func (*SSH) CombinedOutput

func (s *SSH) CombinedOutput(cmd ...string) ([]byte, error)

func (*SSH) CopyFile

func (s *SSH) CopyFile(src, dst string) error

func (*SSH) Exec

func (s *SSH) Exec(cmd ...string) (stdout string, stderr string, exit int, err error)

func (*SSH) LookPath

func (s *SSH) LookPath(file string) (string, error)

func (*SSH) Ping

func (s *SSH) Ping() error

func (*SSH) ReadFile

func (s *SSH) ReadFile(filename string) ([]byte, error)

func (*SSH) Run

func (s *SSH) Run(cmd ...string) error

func (*SSH) Stat

func (s *SSH) Stat(p string) (os.FileInfo, error)

func (*SSH) WriteFile

func (s *SSH) WriteFile(src io.Reader, dst string) error

Jump to

Keyboard shortcuts

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