libscp

package
v0.0.0-...-1f25f5a Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgentConfig

func AgentConfig(u string) (*ssh.ClientConfig, error)

AgentConfig is used to create the SSH Client Configuration when using the SSH Agent for the authentication mechanism

func Get

func Get() (agent.Agent, error)

Get is used to retrieve the agent connection for use via SSH

func KeyConfig

func KeyConfig(u string, k *Key) (*ssh.ClientConfig, error)

KeyConfig is used to create the SSH Client Configuration when using raw SSH key files rather than the SSH Agent for the authentication mechanism

func SendFileWithAgent

func SendFileWithAgent(username, arg, port string) (logrus.Fields, error)

SendFileWithAgent is used to send a file's contents while using ssh agent for retrieving the necessary username information

Types

type Client

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

Client is the remote machine that should be connected to for the transfer. Specifically, what hostname and port.

func NewAgentClient

func NewAgentClient(addr, port string, creds *Credentials) *Client

NewAgentClient creates a new host object that will connect using the SSH Agent signers

func NewKeyClient

func NewKeyClient(addr, port string, creds *Credentials, key *Key) *Client

NewKeyClient creates a new host object that will connect using the SSH Agent signers

func (*Client) Connect

func (c *Client) Connect() error

Connect takes the host object and connects, creating an SSH Client connection

func (*Client) ExecuteCommand

func (c *Client) ExecuteCommand(cmd string) (string, error)

ExecuteCommand is used to

func (*Client) ReceiveFileFromRemote

func (c *Client) ReceiveFileFromRemote(remoteFilePath string, remoteFilename string, localFilePath string, localFileName string) error

ReceiveFileFromRemote is used to receive a file using the SCP protocol from a remote host / machine

func (*Client) SendFileToRemote

func (c *Client) SendFileToRemote(fp string) error

SendFileToRemote is used to send a file using the SCP protocol to a remote host or machine

func (*Client) VerifyClient

func (c *Client) VerifyClient() error

VerifyClient checks if we have a client, and if not attempts to connect

type Credentials

type Credentials struct {
	Username string
	Password string
}

Credentials are the SSH credentials that should be used to connect to the remote host. This is for use with the SSH Agent.

func NewCredentials

func NewCredentials(u, p string) *Credentials

NewCredentials creates a new credential object

type Key

type Key struct {
	P string
	N string
}

Key represents where an SSH Key should be read from. This is commonly used when the SSH agent is not used.

func NewKey

func NewKey(path, name string) (*Key, error)

NewKey is used to create a new SSHKey object and validate that the key file actually exists on the system

func (*Key) Exists

func (s *Key) Exists() bool

Exists validates that the path to the SSH keyfile is valid and that the key actually exists

func (*Key) Path

func (s *Key) Path() string

Path returns the full path to the key file

type SessionClient

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

SessionClient is used to hold the writer for stdout, reader from stdin, wait group for the concurrency, and error channel

func NewSessionClient

func NewSessionClient(s *ssh.Session) (*SessionClient, error)

NewSessionClient creates a new SessionClient structure from the ssh.Session pointer

func (*SessionClient) FileSink

func (c *SessionClient) FileSink(fp, fn string)

FileSink is used to receive a file from the remote machine and save it to the local machine

func (*SessionClient) FileSource

func (c *SessionClient) FileSource(p string)

FileSource allows us to acting as the machine sending a file to the remote host

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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