Documentation ¶
Index ¶
- func AvailableCheck(remote *RemoteServer) (isReachable, havePermission bool)
- func CopyDirectory(client *ssh.Client, selfPath string, remotePath string) (err error)
- func CopyFile(client *ssh.Client, selfPath string, remotePath string) (err error)
- func DialInConsole(addr string, username string) (client *ssh.Client, err error)
- func DialWithCertFile(addr string, username string, clientKeyBytes []byte) (client *ssh.Client, err error)
- func DialWithPassword(addr string, username string, password string) (client *ssh.Client, err error)
- func MustRpcSshCmd(ip string, cmd ...string) []byte
- func MustSshCmdWithCompress(ip string, cmd string) []byte
- func RunCmdWithPassword(cmd, password string)
- func SshCertCopyCertToRemote(cert string, remoteList []RemoteServer)
- func SshCertCopyLocalToRemote(remote *RemoteServer)
- func SshCertCopyLocalToRemoteRoot(remoteAddress string)
- func SudoCommand(client *ssh.Client, cmd string) (err error)
- type RemoteServer
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 ¶
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 ¶
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 ¶
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 MustRpcSshCmd ¶
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)
Types ¶
type RemoteServer ¶
type RemoteServer struct { Address string Password string UserName string //默认 root SshPort int //默认 22 }
func (*RemoteServer) String ¶
func (r *RemoteServer) String() string
Click to show internal directories.
Click to hide internal directories.