Documentation ¶
Overview ¶
Package ssh allows to manage SSH connections and send commands through them.
Index ¶
- func Close(closeable Closeable, ignoreErrors ...string) error
- func NoOpHostKeyCallback(hostname string, remote net.Addr, key ssh.PublicKey) error
- func RunCommandAndGetOutput(host Host, cmd string) (string, error)
- func RunCommandAndGetStdout(host Host, cmd string) (string, error)
- type Closeable
- type Host
- type SSHAgent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoOpHostKeyCallback ¶
NoOpHostKeyCallback is an ssh.HostKeyCallback that does nothing. Only use this when you're sure you don't want to check the host key at all (e.g., only for testing and non-production use cases).
func RunCommandAndGetOutput ¶
RunCommandAndGetOutput will run the given command on the host over SSH and return the combined (stdout + stderr) output.
Types ¶
type Host ¶
type Host struct { Hostname string // host name or ip address SSHUserName string // user name CustomPort int // port number to use to connect to the host (port 22 will be used if unset) JumpHost *Host // Another host to use as a jump host to reach this host. HostKeyCallback ssh.HostKeyCallback // Callback function for handling host key checks. // set one or more authentication methods, // the first valid method will be used PrivateKey string // ssh private key to use as authentication method (disabled by default) SSHAgent bool // enable authentication using your existing local SSH agent (disabled by default) OverrideSSHAgent *SSHAgent // enable an in process `SSHAgent` for connections to this host (disabled by default) Password string // plain text password (blank by default) }
Host is a remote host.
type SSHAgent ¶
type SSHAgent struct {
// contains filtered or unexported fields
}
SSHAgent represents an instance of the ssh-agent process.
func NewSSHAgent ¶
Create SSH agent, start it in background and returns control back to the main thread You should stop the agent to cleanup files afterwards by calling `defer s.Stop()`
func SSHAgentWithPrivateKey ¶
Instantiates and returns an in-memory ssh agent with the given private key already added You should stop the agent to cleanup files afterwards by calling `defer sshAgent.Stop()`
func SSHAgentWithPrivateKeys ¶
Instantiates and returns an in-memory ssh agent with the given private key(s) already added You should stop the agent to cleanup files afterwards by calling `defer sshAgent.Stop()`