modulepackage
0.0.0-20230428145442-34fe18be44e3
Repository: https://github.com/scaredos/simplessh.git
Documentation: pkg.go.dev
# README
simplessh
SimpleSSH is a simple wrapper around go ssh and sftp libraries.
Features
- Multiple authentication methods (password, private key and ssh-agent)
- Sudo support
- Simple file upload/download support
Installation
go get github.com/sfreiberg/simplessh
Example
package main
import (
"fmt"
"github.com/sfreiberg/simplessh"
)
func main() {
/*
Leave privKeyPath empty to use $HOME/.ssh/id_rsa.
If username is blank simplessh will attempt to use the current user.
*/
client, err := simplessh.ConnectWithKeyFile("localhost:22", "root", "/home/user/.ssh/id_rsa")
if err != nil {
panic(err)
}
defer client.Close()
output, err := client.Exec("uptime")
if err != nil {
panic(err)
}
fmt.Printf("Uptime: %s\n", output)
}
License
SimpleSSH is licensed under the MIT license.
# Functions
Connect to an ssh agent.
Connect to an ssh agent with a custom timeout.
Connect with a private key.
Same as ConnectWithKeyFile but allows a custom timeout.
KeyFile with a passphrase.
Connect with a private key with passphrase.
Connect with a private key.
Connect with a private key with passphrase with a custom timeout.
Connect with a private key with a custom timeout.
Connect with a password.
Same as ConnectWithPassword but allows a custom timeout.
# Constants
No description provided by the author
# Variables
Set a default HostKeyCallback variable.