ssh

package
v2.34.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyGeneration     = errors.New("Unable to generate key")
	ErrPrivateKey        = errors.New("Unable to marshal private key")
	ErrPublicKey         = errors.New("Unable to convert public key")
	ErrUnableToWriteFile = errors.New("Unable to write file")
)

Functions

func GenerateSSHKey

func GenerateSSHKey(path string) error

GenerateSSHKey generates SSH keypair based on path of the private key The public key would be generated to the same path with ".pub" added

func RemoveCRCHostEntriesFromKnownHosts

func RemoveCRCHostEntriesFromKnownHosts() error

Types

type Client

type Client interface {
	Run(command string) ([]byte, []byte, error)
	Close()
}

func NewClient

func NewClient(user string, host string, port int, keys ...string) (Client, error)

type KeyPair

type KeyPair struct {
	PrivateKey []byte
	PublicKey  []byte
}

func NewKeyPair

func NewKeyPair() (keyPair *KeyPair, err error)

NewKeyPair generates a new SSH keypair This will return a private & public key encoded as DER.

func (*KeyPair) WriteToFile

func (kp *KeyPair) WriteToFile(privateKeyPath string, publicKeyPath string) error

WriteToFile writes keypair to files

type NativeClient

type NativeClient struct {
	User     string
	Hostname string
	Port     int
	Keys     []string
	// contains filtered or unexported fields
}

func (*NativeClient) Close

func (client *NativeClient) Close()

func (*NativeClient) Run

func (client *NativeClient) Run(command string) ([]byte, []byte, error)

type Runner

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

func CreateRunner

func CreateRunner(ip string, port int, privateKeys ...string) (*Runner, error)

func (*Runner) Close

func (runner *Runner) Close()

func (*Runner) CopyData

func (runner *Runner) CopyData(data []byte, destFilename string, mode os.FileMode) error

func (*Runner) CopyDataPrivileged

func (runner *Runner) CopyDataPrivileged(data []byte, destFilename string, mode os.FileMode) error

func (*Runner) CopyFile

func (runner *Runner) CopyFile(srcFilename string, destFilename string, mode os.FileMode) error

func (*Runner) CopyFileFromVM

func (runner *Runner) CopyFileFromVM(srcFilename string, destFilename string, mode os.FileMode) error

func (*Runner) Run

func (runner *Runner) Run(cmd string, args ...string) (string, string, error)

func (*Runner) RunPrivate

func (runner *Runner) RunPrivate(cmd string, args ...string) (string, string, error)

func (*Runner) RunPrivileged

func (runner *Runner) RunPrivileged(reason string, cmdAndArgs ...string) (string, string, error)

func (*Runner) WaitForConnectivity

func (runner *Runner) WaitForConnectivity(ctx context.Context, timeout time.Duration) error

Jump to

Keyboard shortcuts

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