Gossh

command module
v0.0.0-...-56099e8 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2022 License: MIT Imports: 5 Imported by: 0

README

Gossh

SSH Agent

import (
	"fmt"
	sshx "github.com/EZVIK/Gossh/sshx"
	"golang.org/x/crypto/ssh"
	"os"
	"time"
)


func main() {

	cfg := ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.Password("password"),
		},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
	}
	gs := sshx.NewSSHClient("192.168.0.1", 22, &cfg)

	defer gs.Close()

	loginInfo, err := gs.Connect()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	fmt.Println(loginInfo)

	resp, err := gs.Exec(sshx.CliCommands{
		Command: []string{
			"docker ps",
		},
		Timeout: time.Second * 60,
	})

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	text := ""
	for _, r := range resp["docker ps"] {
		text += r + "\n"
	}

	fmt.Println(text)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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