Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublicKeyFile ¶
func PublicKeyFile(file string) ssh.AuthMethod
PublicKeyFile If you want to authenticate by using SSH certificate you need to create a public key file. You can parse your private key file by using ssh.ParsePrivateKey function. This is required by ssh.PublicKeys auth method function that creates ssh.AuthMethod instance from private key.
func SSHAgent ¶
func SSHAgent(sshAuth string) ssh.AuthMethod
SSHAgent is a program that runs during user session in *nix system. It stores the private keys in an encrypted form. Because typing the passphrase can be tedious, many users would prefer to use it to store their private keys. You can obtain all stored keys via sshAuth variable which stores the SSH agent unix socket. We should access the keys by calling net.Dial and then instance an agent client used by ssh.PublicKeysCallback factory auth method.
Types ¶
type Endpoint ¶
Endpoint The tunneling protocol allows a network user to access or provide a network service that the underlying network does not support or provide directly. There are three type of server: - remote server - local server - target server each server can be represented by the following struct.
type SSHClient ¶
type SSHClient struct { Server *Endpoint Config *ssh.ClientConfig TerminalConfig *SSHTerminal // contains filtered or unexported fields }
SSHClient using SSH client to run a shell command on a remote machine. Every SSH connection requires an ssh.ClientConfig object that defines configuration options such as authentication. Session is one of the parameters that acts as an entry point to the remote terminal.
func (*SSHClient) Connect ¶
Connect opening a new connection to remote machine and creating a new session.
func (*SSHClient) RunCommand ¶
func (client *SSHClient) RunCommand(cmd *SSHCommand) error
RunCommand executes commands.
type SSHCommand ¶
type SSHCommand struct { Path string Env []string Stdin io.Reader Stdout io.Writer Stderr io.Writer }
SSHCommand is used for sending and receiving commands to our remote machine.
type SSHTerminal ¶
type SSHTerminal struct { Echo uint32 TtyOpInputSpeed uint32 TtyOpOutputSpeed uint32 Columns int Rows int }
SSHTerminal to run the command on the remote machine, we should create a pseudo terminal on the remote machine. A pseudo-terminal (or “pty”) is a pair of virtual character devices that provide a bidirectional communication channel.
type SSHTunnel ¶
type SSHTunnel struct { Local *Endpoint Server *Endpoint Remote *Endpoint Config *ssh.ClientConfig }
SSHTunnel The client is connecting to local endpoint. Then the server endpoint mediates between local endpoint and remote endpoint. The algorithm is encapsulated in SSHTunnel struct.