modulepackage
1.1.3
Repository: https://github.com/ngrsoftlab/ssh-executor.git
Documentation: pkg.go.dev
# README
ssh-executor
Lib for local/remote ssh operations.
- connect
- exec statements (also with sudo, also with parsing output)
- send files through scp
import
import (
sshExecutor "github.com/NGRsoftlab/ssh-executor"
)
examples
// exec "ls -la /home/myuser" command on remote "155.34.34.1"
out, _ := sshExecutor.GetSudoCommandsOutWithoutErr(
sshExecutor.ConnectParams{
Host: "155.34.34.1",
Port: 22,
PrivateKey: MyConfig.SSHPrivateKey(), // MyConfig - smth like app configuration obj
},
time.Second * 30,
time.Second * 30,
"ls -la /home/myuser",
)
// let's see command output
fmt.Println(out)
# Functions
GetCommandOutWithErr get result command output (with errOut) from ssh connection.
GetSshConnection getting ssh connection.
GetSudoCommandsOutWithoutErr get result sudo (!) commands..
LocalExecContext local execution command with context.
SendFileWithScp get result command output (with errOut) from ssh connection.
# Structs
Connection ssh connection struct.
ConnectParams params for ssh connection.
FilePathParams params for scp file sending.