GOSSH

gossh: A small Go utility package to handle easier SSH operations such as different kinds of SSH connections (user/pass, private key or signed certificate), command execution, file transfer with SCP protocol.

Currently, it supports:

  • Connection with user & password
  • Connection with SSH key pair
  • Connection with signed SSH certificate
  • SCP content, files or directories recursively from local to remote hosts
  • SCP files or directories recursively from remote hosts to local
config, err := NewClientConfigWithUserPass("user", "pass", "myremotemachine.com", 22, false)
  if err != nil {
    return err
  }

client, err := NewClient(config)
if err != nil {
    return err
}

// execute remote program
res, err := client.ExecCommand("ls -la")

// send a file
err = client.SCPSendFile("./data/scp_single_file", "/tmp/scp_single_file", "0777")
Publikováno v Go