ssh

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SamplePrivKey = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA2eP2yEw47wYi7DCgNKDAswlR4rRSKpDSOGnYst1Tj2Lkt6BH
3HWMUCgSZfCG2JzE6WSZaOsKrSxvq6+n0qSOxm8CR8TlJcpIerFycR1IioAPOTaT
RtDVZnQEIDGH7TCEJHFZZ600IiIeQF2JOfiqe8FbDlw/Z8AqWTn5Vh5aIq32MosO
3BUkHku9lgTj1NyGc0al20nSCf/btdlH/oQQVtUJNwfYj/jx/dvfg70pD9IINR5r
S9dwgfNi5Uk1nwscY2pduA9rp1TB9uXQUyFvFjIMslrR0jcCIXXuiVg7Fc+Uttqr
YH9+qVPTSrWwb6Mm4VEwY2RVOBhzvZ9Sp/RoXQIDAQABAoIBAQC8vwfw3G5ZSASK
e1jcHgCvVrxzWObwboFcUvxffPA8fltIYfS+GamRahT970ywaaT91KI7y5d1CdA2
djQ3eUsgw9rC1uH1SXRdrEdJiydiqqoFUqxjpNWnKYrFZIKtyeA+PV5IPDaz9sAj
26La7/imuYkqOGjIdCN7JYhCvIoyDMx5iNlTGgBK/fmHrhnFj57fl87Y5ZIcFDl1
7oEq76TeuqT9wGpK0NfC9CfKq4XqhHLEVJLXUlKjBqqd93UTjvZljTjV9rezhsDs
h1MSK54PD1oMH7O1LeQSy0NpkwCHqkccBg+163FLUwre7VokdhqO5wPQP10NUmoR
19FaZ4O1AoGBAPYG1Dbc6xGoYB8vn8rmTFjQodadwIo0qx3a1sN6pQF2gxumerNM
2MSu7TzmaD6A3fHuFS4/0RNzvFOYtQ6OnpzpqjskBSiVmlwo+FIakuqjE+nGYhjI
dgfeYkTf1nhyfwwAmjNxfJBFukryWnXcM2zCjJa7rYH2hCEh5ZZKWs2DAoGBAOK5
JftPRFG45X9JfLcd4MNG5xFfCe6is/6dDlz9HWswm0mKO192mWh58npzXJ/kewX7
UXIhpqOqcKCum2YfbR2t2mw80oYDjZ4rgSdBiB4aQA4i1DGAUweUXFkSZZlWntp0
ucxRLLflCfjjtk7ozmVoWU+HgxsvpxNF/WgaXuyfAoGBAOhDtC8DS00FR5HJlTKp
TqR+ensxvOb9KBrsUdqEO6jw6H+/IJGLWA3/EutunjV71Yyj9w0NpGWX2tCVF0Fh
9W4vzs08iT4yVmLxLtXcTp0DTjZiWpQJFB0DnoRlSYW2miiLnQg5+J3/pgtBV5Nz
Sn1AAhf/oKNURpM8/BFxqt3fAoGBAIF+rqrzg1oJ+UrSdmFAt3fRr3jEh6+9ToFG
w0VpbLwkbw153p+P5d8+h7hY27aXkYzBFqvRfJRObTXZhPi3SmOBQRhBRR02OlT1
FDePvmczJxLr4bbETKgvnO9jCpSiXOj5coW4d4oxT5jQtvgrEHfrOdeq1r9YYF0p
xKsJJN6RAoGAY0dKncvCQaBnKEsdnYXGZTkiWkbP3f9lvHqcpsNOeMionSn+MNNV
eLSIhRZBZeDbd5/GJsmKcXPqD6St3nShObjJva8/zw63sBT9nng65RuU2oyCnSwu
NdnXpXB1bDYDbc3Gy33eJck6czWrHsOREM/d4L8xBfTSzr24I36qk5Y=
-----END RSA PRIVATE KEY-----`)

SamplePrivKey is taken from go.crypto's testdata.

Functions

func PrivateKey

func PrivateKey(pemData []byte) func(*Server) error

PrivateKey sets the server's private key and host key.

func Verbose

func Verbose(s *Server) error

Verbose enables verbose logging.

Types

type KnownHost

type KnownHost struct {
	Hostnames []string // unhashed hostnames (represented as comma-separated names in the original file)

	Salt, Hash []byte // hashed hostname

	Key ssh.PublicKey
}

A KnownHost is a hostname and a known host key associated with that hostname. The hostname can be either unhashed or hashed.

func (*KnownHost) Match

func (h *KnownHost) Match(hostname string) bool

Match returns whether hostname matches this known host entry's unhashed hostnames (separated by comma) or the hashed hostname.

type KnownHosts

type KnownHosts []*KnownHost

KnownHosts is a collection of known hosts and their host keys. Because hostname key may be hashed, use Lookup to get the host keys for a hostname instead of simply iterating over them and checking the Hostname field.

func ParseKnownHosts

func ParseKnownHosts(r io.Reader) (KnownHosts, error)

ParseKnownHosts parses an SSH known_hosts file.

func ReadKnownHostsFile

func ReadKnownHostsFile(path string) (KnownHosts, error)

ReadKnownHostsFile reads the known_hosts file at path.

func ReadStandardKnownHostsFiles

func ReadStandardKnownHostsFiles() (KnownHosts, error)

ReadStandardKnownHostsFiles reads and parses the known_hosts files at /etc/ssh/ssh_known_hosts and ~/.ssh/known_hosts.

func (KnownHosts) Lookup

func (khs KnownHosts) Lookup(hostname string) (hostKeys []ssh.PublicKey, found bool)

Lookup looks up hostname (which must be an unhashed hostname) in the known hosts collection. It returns host keys that match the unhashed hostname and the hashed variant of it. If any host keys are found, found is true; otherwise it is false.

type Server

type Server struct {
	Shell string
	Dir   string

	SSH ssh.ServerConfig

	GitURL string
	// contains filtered or unexported fields
}

Server is an SSH server.

func NewServer

func NewServer(shell, dir string, opt ...func(*Server) error) (*Server, error)

NewServer creates a new test SSH server that runs a shell command upon login (with the current directory set to dir). It can be used to test remote SSH communication.

func (*Server) Close

func (s *Server) Close() error

func (*Server) Start

func (s *Server) Start() error

Start starts the server in a goroutine. If the server was unable to start, an error is returned.

Jump to

Keyboard shortcuts

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