# README
Origin README see here
This ssh package contains helpers for working with ssh in go. The client.go
file
is a modified version of docker/machine/libmachine/ssh/client.go
that only
uses golang's native ssh client. It has also been improved to resize the tty as
needed. The key functions are meant to be used by either client or server
and will generate/store keys if not found.
Usage:
package main
import (
"fmt"
"github.com/nanobox-io/golang-ssh"
)
func main() {
err := connect()
if err != nil {
fmt.Printf("Failed to connect - %s\n", err)
}
}
func connect() error {
nanPass := ssh.Auth{Passwords: []string{"pass"}}
client, err := ssh.NewNativeClient("user", "localhost", "SSH-2.0-MyCustomClient-1.0", 2222, &nanPass, nil)
if err != nil {
return fmt.Errorf("Failed to create new client - %s", err)
}
err = client.Shell()
if err != nil && err.Error() != "exit status 255" {
return fmt.Errorf("Failed to request shell - %s", err)
}
return nil
}
Compile for Windows:
If you get this error:
go: github.com/Sirupsen/[email protected]: parsing go.mod: unexpected module path "github.com/sirupsen/logrus"
when compile for Windows with go mod
, see this issue
for some hints and there was a walkaround:
go mod init
go get github.com/docker/[email protected]
GOOS=windows GOARCH=amd64 go build
# Functions
GenKeyPair make a pair of public and private keys for SSH access.
GetKeyPair will attempt to get the keypair from a file and will fail back to generating a new set and saving it to the file.
NewNativeClient creates a new Client using the golang ssh library.
No description provided by the author
NewNativeConfig returns a golang ssh client config struct for use by the NativeClient.
# Constants
No description provided by the author
No description provided by the author
# Structs
Auth contains auth info.
Config is used to create new client.
ExitError is a conveniance wrapper for (crypto/ssh).ExitError type.
HopDetails stores open sessions and connections which need to be tracked so they can be properly cleaned up.
No description provided by the author
No description provided by the author
NativeClient is the structure for native client use.
SessionInfo contains artifacts from the session that need to be cleaned up.
# Interfaces
Client is a relic interface that both native and external client matched.