kmgSsh

package
v0.0.0-...-05317bf Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2015 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableCheck

func AvailableCheck(remote *RemoteServer) (isReachable, havePermission bool)

每次尝试连接,5秒超时,超时后,重试12次,最多等1分钟 若 isReachable = false,则 havePermission 没有有意义

func CopyDirectory

func CopyDirectory(client *ssh.Client, selfPath string, remotePath string) (err error)

transfer a directory to remote host,with single tcp and tar.gz format Stdout will be ignore. Stderr will treat as an error from remote command

func CopyFile

func CopyFile(client *ssh.Client, selfPath string, remotePath string) (err error)

transfer a file to remote host,with single tcp and gz format Stdout will be ignore. Stderr will treat as an error from remote command TODO test

func DialInConsole

func DialInConsole(addr string, username string) (client *ssh.Client, err error)

TODO 某种认证方法只有一个会被使用,需要多次猜测

func DialWithCertFile

func DialWithCertFile(addr string, username string, clientKeyBytes []byte) (client *ssh.Client, err error)

DialWithCertFile addr like 127.0.0.1:22 username is the username on that remote machine clientKey is the content of ~/.ssh/id_rsa

func DialWithPassword

func DialWithPassword(addr string, username string, password string) (client *ssh.Client, err error)

func MustRpcSshCmd

func MustRpcSshCmd(ip string, cmd ...string) []byte

func MustSshCmdWithCompress

func MustSshCmdWithCompress(ip string, cmd string) []byte

带压缩的ssh下载

func RunCmdWithPassword

func RunCmdWithPassword(cmd, password string)

func SshCertCopyCertToRemote

func SshCertCopyCertToRemote(cert string, remoteList []RemoteServer)

func SshCertCopyLocalToRemote

func SshCertCopyLocalToRemote(remote *RemoteServer)

func SshCertCopyLocalToRemoteRoot

func SshCertCopyLocalToRemoteRoot(remoteAddress string)

func SudoCommand

func SudoCommand(client *ssh.Client, cmd string) (err error)

run sudo a command in remote and ask password in current console, Stdout will goto current console too. Stderr will treat as an error from remote command

Types

type RemoteServer

type RemoteServer struct {
	Address  string
	Password string
	UserName string //默认 root
	SshPort  int    //默认 22
}

func (*RemoteServer) String

func (r *RemoteServer) String() string

Jump to

Keyboard shortcuts

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