omgossh

command module
v0.0.0-...-e636870 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: AGPL-3.0 Imports: 6 Imported by: 0

README

oh my gossh

Oh My GoSSH is a simple library for Golang which allows you to connect via ssh to any remote server using username and password.

Use at your own risk.

Usage

package main

import (
  "fmt"
  omgossh "github.com/micheleriva/omgossh"
)

const SSH_HOST     = os.Getenv("SSH_HOST")
const SSH_USERNAME = os.Getenv("SSH_USERNAME")
const SSH_PASSWORD = os.Getenv("SSH_PASSWORD")

func main() {

  conn, err := omgossh.Connect(SSH_HOST, SSH_USERNAME, SSH_PASSWORD)
  if err != nil {
    log.Fatal(err)
  }

  stdout, err := conn.Exec("cd /myDir", "ls -la")
  if err != nil {
    log.Fatal(err)
  }

  fmt.Println(stdout)
}
go run .

# Now we should see the result of "cd /myDir" and "ls -la" commands
drwxr-xr-x  7 root root  224 Sep 16 20:15 ./
drwxr-xr-x  8 root root  256 Sep 16 20:15 ../
-rw-r--r--  1 root root  691 Sep 16 20:15 README.md

License

GPLv3

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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