ssh

package
v0.0.0-...-8a1a740 Latest Latest
Warning

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

Go to latest
Published: May 29, 2021 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright © 2021 Nikhil Prabhu

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Password

func Password(pword string) ssh.AuthMethod

Password parses a string into an SSH password

func PublicKey

func PublicKey(file string) (ssh.AuthMethod, error)

PublicKey parses a private key and returns a public key

Types

type ConnectionParams

type ConnectionParams struct {
	User    string
	Addr    string
	Auth    ssh.AuthMethod
	HostKey string
}

ConnectionParams are the parameters required to establish an SSH connection

type SSHClient

type SSHClient struct {
	*ssh.Client
}

We define a custom SSH client type so we can define our own methods for it

func Connect

func Connect(c ConnectionParams) (*SSHClient, error)

Connect establishes an SSH connection with a specified address and returns the client. For ports other than the default (22), the port number must be appended to the address

Example: 192.168.2.122:2222

func (*SSHClient) Copy

func (s *SSHClient) Copy(src, dest string) error

Copy copies a file or a directory from a local source to a remote destination

func (*SSHClient) RunCmd

func (s *SSHClient) RunCmd(cmd string) (stdout string, stderr string, err error)

RunCmd runs a command on the remote machine and returns its stdout and stderr

Jump to

Keyboard shortcuts

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