ssh

package
v4.0.0-rc13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2017 License: MIT Imports: 12 Imported by: 517

Documentation

Overview

Package ssh implements the SSH transport protocol.

Index

Constants

View Source
const (
	KeyboardInteractiveName = "ssh-keyboard-interactive"
	PasswordName            = "ssh-password"
	PasswordCallbackName    = "ssh-password-callback"
	PublicKeysName          = "ssh-public-keys"
	PublicKeysCallbackName  = "ssh-public-key-callback"
)

The names of the AuthMethod implementations. To be returned by the Name() method. Most git servers only allow PublicKeysName and PublicKeysCallbackName.

View Source
const DefaultPort = 22
View Source
const DefaultUsername = "git"

Variables

View Source
var DefaultAuthBuilder = func(user string) (AuthMethod, error) {
	return NewSSHAgentAuth(user)
}

DefaultAuthBuilder is the function used to create a default AuthMethod, when the user doesn't provide any.

View Source
var DefaultClient = NewClient(nil)

DefaultClient is the default SSH client.

Functions

func NewClient

func NewClient(config *ssh.ClientConfig) transport.Transport

NewClient creates a new SSH client with an optional *ssh.ClientConfig.

func NewKnownHostsCallback

func NewKnownHostsCallback(files ...string) (ssh.HostKeyCallback, error)

NewKnownHostsCallback returns ssh.HostKeyCallback based on a file based on a know_hosts file. http://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT

If files is empty, the list of files will be read from the SSH_KNOWN_HOSTS environment variable, example:

/home/foo/custom_known_hosts_file:/etc/custom_known/hosts_file

If SSH_KNOWN_HOSTS is not set the following file locations will be used:

~/.ssh/known_hosts
/etc/ssh/ssh_known_hosts

Types

type AuthMethod

type AuthMethod interface {
	transport.AuthMethod
	// contains filtered or unexported methods
}

AuthMethod is the interface all auth methods for the ssh client must implement. The clientConfig method returns the ssh client configuration needed to establish an ssh connection.

func NewPublicKeys

func NewPublicKeys(user string, pemBytes []byte, password string) (AuthMethod, error)

NewPublicKeys returns a PublicKeys from a PEM encoded private key. An encryption password should be given if the pemBytes contains a password encrypted PEM block otherwise password should be empty. It supports RSA (PKCS#1), DSA (OpenSSL), and ECDSA private keys.

func NewPublicKeysFromFile

func NewPublicKeysFromFile(user, pemFile, password string) (AuthMethod, error)

NewPublicKeysFromFile returns a PublicKeys from a file containing a PEM encoded private key. An encryption password should be given if the pemBytes contains a password encrypted PEM block otherwise password should be empty.

func NewSSHAgentAuth

func NewSSHAgentAuth(u string) (AuthMethod, error)

NewSSHAgentAuth returns a PublicKeysCallback based on a SSH agent, it opens a pipe with the SSH agent and uses the pipe as the implementer of the public key callback function.

type KeyboardInteractive

type KeyboardInteractive struct {
	User      string
	Challenge ssh.KeyboardInteractiveChallenge
	// contains filtered or unexported fields
}

KeyboardInteractive implements AuthMethod by using a prompt/response sequence controlled by the server.

func (*KeyboardInteractive) Name

func (a *KeyboardInteractive) Name() string

func (*KeyboardInteractive) String

func (a *KeyboardInteractive) String() string

type Password

type Password struct {
	User string
	Pass string
	// contains filtered or unexported fields
}

Password implements AuthMethod by using the given password.

func (*Password) Name

func (a *Password) Name() string

func (*Password) String

func (a *Password) String() string

type PasswordCallback

type PasswordCallback struct {
	User     string
	Callback func() (pass string, err error)
	// contains filtered or unexported fields
}

PasswordCallback implements AuthMethod by using a callback to fetch the password.

func (*PasswordCallback) Name

func (a *PasswordCallback) Name() string

func (*PasswordCallback) String

func (a *PasswordCallback) String() string

type PublicKeys

type PublicKeys struct {
	User   string
	Signer ssh.Signer
	// contains filtered or unexported fields
}

PublicKeys implements AuthMethod by using the given key pairs.

func (*PublicKeys) Name

func (a *PublicKeys) Name() string

func (*PublicKeys) String

func (a *PublicKeys) String() string

type PublicKeysCallback

type PublicKeysCallback struct {
	User     string
	Callback func() (signers []ssh.Signer, err error)
	// contains filtered or unexported fields
}

PublicKeysCallback implements AuthMethod by asking a ssh.agent.Agent to act as a signer.

func (*PublicKeysCallback) Name

func (a *PublicKeysCallback) Name() string

func (*PublicKeysCallback) String

func (a *PublicKeysCallback) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL