ssh

package
v0.8.14 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodePrivateKey added in v0.8.14

func EncodePrivateKey(private *rsa.PrivateKey) []byte

func EncodePublicKey added in v0.8.14

func EncodePublicKey(public *rsa.PublicKey) ([]byte, error)

func EncodeSSHKey added in v0.8.14

func EncodeSSHKey(public *rsa.PublicKey) ([]byte, error)

func GenerateKey added in v0.8.14

func GenerateKey(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

func MakePrivateKeySignerFromBytes added in v0.8.14

func MakePrivateKeySignerFromBytes(buffer []byte) (ssh.Signer, error)

func MakePrivateKeySignerFromFile added in v0.8.14

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

func ParsePublicKeyFromFile added in v0.8.14

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

func RunSSHCommand added in v0.8.14

func RunSSHCommand(cmd, user, host string, signer ssh.Signer) (string, string, int, error)

RunSSHCommand returns the stdout, stderr, and exit code from running cmd on host as specific user, along with any SSH-level error. If user=="", it will default (like SSH) to os.Getenv("USER")

Types

type Result

type Result struct {
	User     string
	Host     string
	Cmd      string
	Stdout   string
	Stderr   string
	Code     int
	SSHError error
}

Result holds the execution result of SSH command.

func Run

func Run(cmd, ip, sshUser, sshKey string) Result

Run synchronously SSHs to a machine and runs cmd.

type SSHTunnelList added in v0.8.14

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

func NewSSHTunnelList added in v0.8.14

func NewSSHTunnelList(user, keyfile string, healthCheckURL *url.URL, stopChan chan struct{}) *SSHTunnelList

func (*SSHTunnelList) Dial added in v0.8.14

func (l *SSHTunnelList) Dial(ctx context.Context, net, addr string) (net.Conn, error)

func (*SSHTunnelList) Update added in v0.8.14

func (l *SSHTunnelList) Update(addrs []string)

Update reconciles the list's entries with the specified addresses. Existing tunnels that are not in addresses are removed from entries and closed in a background goroutine. New tunnels specified in addresses are opened in a background goroutine and then added to entries.

Jump to

Keyboard shortcuts

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