client

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeysDir       = "/tmp/teleport"
	KeyFilePrefix = "teleport_"
	KeyFileSuffix = ".tkey"
)

Variables

This section is empty.

Functions

func AuthMethodFromAgent

func AuthMethodFromAgent(ag agent.Agent) ssh.AuthMethod

func Download

func Download(user, target, proxyAddress, remoteSourcePath, localDestPath string, isDir bool, authMethods []ssh.AuthMethod) error

Download downloads file or dir from target servers, target can be like "127.0.0.1:1234" or "_label:value". Processes for each server work in parallel. If there are more than one target server, result files will be arranged in a folder.

func GetLocalAgent

func GetLocalAgent() (agent.Agent, error)

GetLoadAgent loads all the saved teleport certificates and creates ssh agent with them

func GetTokenFromHOTPMockFile

func GetTokenFromHOTPMockFile(path string) (token string, e error)

GetTokenFromHOTPMockFile opens HOTPMock from file, gets token value, increases hotp and saves it to the file. Returns hotp token value.

func Login

func Login(ag agent.Agent, webProxyAddr string, user string,
	ttl time.Duration, passwordCallback PasswordCallback) error

Login tries to generate teleport certificate using password and hotpToken, adds the certificate to the provided agent and saves the certificate to the local folder.

func NewWebAuth

func NewWebAuth(ag agent.Agent,
	user string,
	passwordCallback PasswordCallback,
	webProxyAddress string,
	certificateTTL time.Duration) ssh.AuthMethod

GenerateCertificateCallback returns ssh.AuthMethod as a callback function. When callback is called, it tries to generate teleport certificate using password and hotpToken, adds the certificate to the provided agent, saves the certificate to the local folder and returns the agent as authenticator.

func ParseTargetServers

func ParseTargetServers(target string, user, proxyAddress string, authMethods []ssh.AuthMethod) ([]string, error)

ParseTargetServers parses target to an array of server addresses, target can be like "127.0.0.1:1234" or "_label:value". If "_label:value" provided, it connects to the proxy server and finds target servers

func RunCmd

func RunCmd(user, target, proxyAddress, command string, authMethods []ssh.AuthMethod) error

RunCmd runs provided command on the target servers and prints result to stdout, target can be like "127.0.0.1:1234" or "_label:value".

func SplitUserAndAddress

func SplitUserAndAddress(target string) (string, string)

SplitUserAndAddress splits target into user and address using "@" as delimiter. If target doesn't contain "@", it returns empty user and target as address

func Upload

func Upload(user, target, proxyAddress, localSourcePath, remoteDestPath string, authMethods []ssh.AuthMethod) error

Upload uploads file or dir to the target servers, target can be like "127.0.0.1:1234" or "_label:value". Processes for each server work in parallel

Types

type HOTPMock

type HOTPMock struct {
	*hotp.HOTP
}

HOTPMock is a HOTP that can be saved or load from file Using HOTPMock disables the hotp security level, don't use it in production

func CreateHOTPMock

func CreateHOTPMock(hotpURLString string) (*HOTPMock, error)

func LoadHOTPMockFromFile

func LoadHOTPMockFromFile(path string) (*HOTPMock, error)

func (*HOTPMock) SaveToFile

func (otp *HOTPMock) SaveToFile(path string) error

type Key

type Key struct {
	Priv     []byte
	Cert     []byte
	Deadline time.Time
}

type NodeClient

type NodeClient struct {
	Client *ssh.Client
}

NodeClient implements ssh client to a ssh node (teleport or any regular ssh node) NodeClient can run shell and commands or upload and download files.

func ConnectToNode

func ConnectToNode(optionalProxy *ProxyClient, nodeAddress string, authMethods []ssh.AuthMethod, user string) (*NodeClient, error)

ConnectToNode returns connected and authenticated NodeClient

func (*NodeClient) Close

func (client *NodeClient) Close() error

func (*NodeClient) Download

func (client *NodeClient) Download(remoteSourcePath, localDestinationPath string, isDir bool) error

Download downloads file or dir from the remote server

func (*NodeClient) Run

func (client *NodeClient) Run(cmd string, output io.Writer) error

Run executes command on the remote server and writes its stdout to the 'output' argument

func (*NodeClient) Shell

func (client *NodeClient) Shell(width, height int) (io.ReadWriteCloser, error)

Shell returns remote shell as io.ReadWriterCloser object

func (*NodeClient) Upload

func (client *NodeClient) Upload(localSourcePath, remoteDestinationPath string) error

Upload uploads file or dir to the remote server

type PasswordCallback

type PasswordCallback func() (password, hotpToken string, e error)

func GetPasswordFromConsole

func GetPasswordFromConsole(user string) PasswordCallback

type ProxyClient

type ProxyClient struct {
	Client *ssh.Client

	*sync.Mutex
	// contains filtered or unexported fields
}

ProxyClient implements ssh client to a teleport proxy It can provide list of nodes or connect to nodes

func ConnectToProxy

func ConnectToProxy(proxyAddress string, authMethods []ssh.AuthMethod,
	user string) (*ProxyClient, error)

ConnectToProxy returns connected and authenticated ProxyClient

func (*ProxyClient) Close

func (proxy *ProxyClient) Close() error

func (*ProxyClient) ConnectToNode

func (proxy *ProxyClient) ConnectToNode(nodeAddress string, authMethods []ssh.AuthMethod, user string) (*NodeClient, error)

ConnectToNode connects to the ssh server via Proxy. It returns connected and authenticated NodeClient

func (*ProxyClient) FindServers

func (proxy *ProxyClient) FindServers(labelName string,
	labelValueRegexp string) ([]services.Server, error)

FindServers returns list of the nodes which have labels "labelName" and corresponding values matches "labelValueRegexp"

func (*ProxyClient) GetServers

func (proxy *ProxyClient) GetServers() ([]services.Server, error)

GetServers returns list of the nodes connected to the proxy

Jump to

Keyboard shortcuts

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