Documentation ¶
Index ¶
- Constants
- func AuthMethodFromAgent(ag agent.Agent) ssh.AuthMethod
- func Download(user, target, proxyAddress, remoteSourcePath, localDestPath string, isDir bool, ...) error
- func GetLocalAgent() (agent.Agent, error)
- func GetTokenFromHOTPMockFile(path string) (token string, e error)
- func Login(ag agent.Agent, webProxyAddr string, user string, ttl time.Duration, ...) error
- func NewWebAuth(ag agent.Agent, user string, passwordCallback PasswordCallback, ...) ssh.AuthMethod
- func ParseTargetServers(target string, user, proxyAddress string, authMethods []ssh.AuthMethod) ([]string, error)
- func RunCmd(user, target, proxyAddress, command string, authMethods []ssh.AuthMethod) error
- func SplitUserAndAddress(target string) (string, string)
- func Upload(user, target, proxyAddress, localSourcePath, remoteDestPath string, ...) error
- type HOTPMock
- type Key
- type NodeClient
- func (client *NodeClient) Close() error
- func (client *NodeClient) Download(remoteSourcePath, localDestinationPath string, isDir bool) error
- func (client *NodeClient) Run(cmd string, output io.Writer) error
- func (client *NodeClient) Shell(width, height int) (io.ReadWriteCloser, error)
- func (client *NodeClient) Upload(localSourcePath, remoteDestinationPath string) error
- type PasswordCallback
- type ProxyClient
- func (proxy *ProxyClient) Close() error
- func (proxy *ProxyClient) ConnectToNode(nodeAddress string, authMethods []ssh.AuthMethod, user string) (*NodeClient, error)
- func (proxy *ProxyClient) FindServers(labelName string, labelValueRegexp string) ([]services.Server, error)
- func (proxy *ProxyClient) GetServers() ([]services.Server, error)
Constants ¶
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 ¶
GetLoadAgent loads all the saved teleport certificates and creates ssh agent with them
func GetTokenFromHOTPMockFile ¶
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 ¶
SplitUserAndAddress splits target into user and address using "@" as delimiter. If target doesn't contain "@", it returns empty user and target as address
Types ¶
type HOTPMock ¶
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 LoadHOTPMockFromFile ¶
func (*HOTPMock) SaveToFile ¶
type NodeClient ¶
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 ¶
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