Documentation
¶
Index ¶
- Constants
- func ReadPipe(stdout, stderr io.Reader, alsoToStdout bool)
- func WaitSSHReady(ssh Interface, tryTimes int, hosts ...net.IP) error
- type Client
- type Interface
- type SSH
- func (s *SSH) Cmd(host net.IP, hostEnv map[string]string, cmd string) ([]byte, error)
- func (s *SSH) CmdAsync(host net.IP, hostEnv map[string]string, cmds ...string) error
- func (s *SSH) CmdToString(host net.IP, env map[string]string, cmd, split string) (string, error)
- func (s *SSH) Connect(host net.IP) (*ssh.Client, *ssh.Session, error)
- func (s *SSH) Copy(host net.IP, localPath, remotePath string) error
- func (s *SSH) CopyR(host net.IP, localFilePath, remoteFilePath string) error
- func (s *SSH) GetPlatform(host net.IP) (v1.Platform, error)
- func (s *SSH) IsFileExist(host net.IP, remoteFilePath string) (bool, error)
- func (s *SSH) NewSudoSftpClient(conn *ssh.Client, opts ...sftp.ClientOption) (*sftp.Client, error)
- func (s *SSH) Ping(host net.IP) error
- func (s *SSH) RemoteDirExist(host net.IP, remoteDirPath string) (bool, error)
Constants ¶
View Source
const DefaultSSHPort = "22"
View Source
const (
Md5sumCmd = "md5sum %s | cut -d\" \" -f1"
)
View Source
const SUDO = "sudo "
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Interface ¶
type Interface interface {
// Copy local files to remote host
// scp -r /tmp root@192.168.0.2:/root/tmp => Copy("192.168.0.2","tmp","/root/tmp")
// need check md5sum
Copy(host net.IP, srcFilePath, dstFilePath string) error
// CopyR copy remote host files to localhost
CopyR(host net.IP, srcFilePath, dstFilePath string) error
// CmdAsync exec command on remote host, and asynchronous return logs
CmdAsync(host net.IP, env map[string]string, cmd ...string) error
// Cmd exec command on remote host, and return combined standard output and standard error
Cmd(host net.IP, env map[string]string, cmd string) ([]byte, error)
// CmdToString exec command on remote host, and return spilt standard output and standard error
CmdToString(host net.IP, env map[string]string, cmd, spilt string) (string, error)
// IsFileExist check remote file exist or not
IsFileExist(host net.IP, remoteFilePath string) (bool, error)
// RemoteDirExist Remote file existence returns true, nil
RemoteDirExist(host net.IP, remoteDirpath string) (bool, error)
// GetPlatform Get remote platform
GetPlatform(host net.IP) (v1.Platform, error)
// Ping Ping remote host
Ping(host net.IP) error
}
func GetHostSSHClient ¶
GetHostSSHClient is used to executed bash command and no std out to be printed.
type SSH ¶
type SSH struct {
AlsoToStdout bool
Encrypted bool
User string
Password string
Port string
PkFile string
PkPassword string
Timeout *time.Duration
LocalAddress []net.Addr
Fs fs.Interface
}
func (*SSH) CmdToString ¶
CmdToString is in host exec cmd and replace to spilt str
func (*SSH) GetPlatform ¶ added in v0.9.0
func (*SSH) IsFileExist ¶
func (*SSH) NewSudoSftpClient ¶
Click to show internal directories.
Click to hide internal directories.