repositorypackage
0.0.12
Repository: https://github.com/matthewmueller/sshx.git
Documentation: pkg.go.dev
# README
sshx
Tiny wrapper around golang.org/x/crypto/ssh that has better defaults. Returns an *golang.org/x/crypto/ssh.Client
that can be used elsewhere
The goal being it works exactly like if you did ssh user@host
on your machine.
Features
- Handles
~/.ssh/known_hosts
on OSX thanks to skeema/knownhosts. - Uses the active SSH agent on your machine if there is one, allowing you to seamlessly connect without providing a private key (and often the password needed to decrypt that private key).
- Adds
Run(ssh, cmd) (stdout, error)
andExec(ssh, cmd) error
commands. - Allocate an interactive shell with
sshx.Shell(sshClient, workDir)
Example
// Dial a server
client, err := sshx.Dial("vagrant", "127.0.0.1:2222")
if err != nil {
// handle error
}
defer client.Close()
// Run a command
stdout, err := sshx.Run(client, "ls -al")
if err != nil {
// handle error
}
Install
go get github.com/matthewmueller/sshx
Development
First, clone the repo:
git clone https://github.com/matthewmueller/sshx
cd sshx
Next, install dependencies:
go mod tidy
Finally, try running the tests:
go test ./...
License
MIT