Shell

package module
v0.0.0-...-e53d5f6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 10 Imported by: 0

README

SSH Client Script

FOSSA Status

SSH Shell with Go Programming

Install


    go get github.com/kevsersrca/secureshell

Usage


    package main

    import(
        s"github.com/kevsersrca/secureshell"
    )
    func main() {
            client, err := s.ConnectWithKeyFile("localhost:22", "root", "/home/user/.ssh/id_rsa")
        	if err != nil {
        		panic(err)
        	}
        	defer client.Close()
        
        	output, err := client.Exec("uptime -p")
        	if err != nil {
        		panic(err)
        	}
        	fmt.Println(output)
    }

License

FOSSA Status

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

Variables

View Source
var HostKeyCallback = ssh.InsecureIgnoreHostKey()

Functions

This section is empty.

Types

type Client

type Client struct {
	SSHClient *ssh.Client
}

func ConnectWithKeyFile

func ConnectWithKeyFile(host, username, privKeyPath string) (*Client, error)

func ConnectWithPassword

func ConnectWithPassword(host, username, pass string) (*Client, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) Exec

func (c *Client) Exec(cmd string) ([]byte, error)

func (*Client) ExecRoot

func (c *Client) ExecRoot(cmd, passwd string) ([]byte, error)

Jump to

Keyboard shortcuts

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