Documentation
¶
Overview ¶
Package ssh provides users with a simple interface for remote execution over SSH. While this package is for Efs2 it could easily be imported and used by others.
// Read a Key File
key, err := ssh.ReadKeyFile("~/.ssh/id_rsa", "aPass")
if err != nil {
// do something
}
// Dial the remote host
conn, err := ssh.Dial(ssh.Config{
Host: "example.com:22",
User: "example",
Key: key,
})
if err != nil {
// do something
}
// Upload a File
err = conn.Put(ssh.File{...})
if err != nil {
// do something
}
// Run a Command
output, err := conn.Run(ssh.Command{...})
if err != nil {
// do something
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// Cmd is the single line shell command for execution.
Cmd string
}
Command is a structure that holds details for individual commands that execute remotely.
type Config ¶
type Config struct {
// Host contains the remote SSH host address in a hostname:port format. If no port is specified, the Dial function will return an error.
Host string
// User contains the remote host's username to use for authentication and must not be left blank.
User string
// Key provides an SSH key to use for authentication. This key is the private key and requires the public key to be pre-pushed to the remote host for authentication to work.
Key ssh.Signer
// Password provides a password to use for authentication. If the password is present, the Dial function will ignore the SSH Key authentication settings.
Password string
}
Config provides SSH client configuration details to the Dial function. This configuration offers items such as hostname, port, username, and SSH Keys to use for authentication.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn is an SSH connection the internally holds both an SSH and SFTP session.
func Dial ¶
Dial will open an SSH connection to the configured remote host. The returned connection can then upload files or execute commands.
func (*Conn) Close ¶
func (c *Conn) Close()
Close will close the open SSH connection cleaning up any lingering executions.
type File ¶
type File struct {
// Source is the full path to the source file to be uploaded.
Source string
// Destination is the full path location of the destination filename.
Destination string
// Mode is the file permissions to be set upon upload.
Mode os.FileMode
}
File is a structure that holds the details required for uploading files.
type Task ¶
type Task struct {
// Task is the original instruction used to create the task.
Task string
// Command is a command structure that provides command execution instructions.
Command Command
// File is a file structure that provides file upload instructions.
File File
}
Task is a wrapper structure used during parsing of Efs2 files. Within this structure contains SSH command and file structures.