Documentation ¶
Index ¶
- Variables
- func FindSSHAuthorizedKeysFile(ctx context.Context, exec ctxt.Executor) string
- func NewSSH_Key(user, privateKeyPath, host string, port int) (*ssh.Client, error)
- func NewSftpClient(sshClient *ssh.Client) (*sftp.Client, error)
- func NewSshByPwd(user, password, host string, port int) (*ssh.Client, error)
- func NewSshSession(sshClient *ssh.Client) (*ssh.Session, error)
- func UploadFile(ip string, localFilePath string, remoteDir string, sftpClient *sftp.Client) error
- type EasySSHExecutor
- type SSHConfig
- type SSHType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrPropSSHCommand is ErrPropSSHCommand ErrPropSSHCommand = errorx.RegisterPrintableProperty("ssh_command") // ErrPropSSHStdout is ErrPropSSHStdout ErrPropSSHStdout = errorx.RegisterPrintableProperty("ssh_stdout") // ErrPropSSHStderr is ErrPropSSHStderr ErrPropSSHStderr = errorx.RegisterPrintableProperty("ssh_stderr") // ErrSSHExecuteFailed is ErrSSHExecuteFailed ErrSSHExecuteFailed = errNSSSH.NewType("execute_failed") // ErrSSHExecuteTimedout is ErrSSHExecuteTimedout ErrSSHExecuteTimedout = errNSSSH.NewType("execute_timedout") )
Functions ¶
func FindSSHAuthorizedKeysFile ¶
FindSSHAuthorizedKeysFile finds the correct path of SSH authorized keys file
Types ¶
type EasySSHExecutor ¶
type EasySSHExecutor struct { Config *easyssh.MakeConfig Locale string // the locale used when executing the command Sudo bool // all commands run with this executor will be using sudo }
EasySSHExecutor implements Executor with EasySSH as transportation layer.
func (*EasySSHExecutor) Execute ¶
func (e *EasySSHExecutor) Execute(ctx context.Context, cmd string, sudo bool, timeout ...time.Duration) ([]byte, []byte, error)
Execute run the command via SSH, it's not invoking any specific shell by default.
func (*EasySSHExecutor) Transfer ¶
func (e *EasySSHExecutor) Transfer(ctx context.Context, src, dst string, download bool, limit int, compress bool) error
Transfer copies files via SCP This function depends on `scp` (a tool from OpenSSH or other SSH implementation) This function is based on easyssh.MakeConfig.Scp() but with support of copying file from remote to local.
type SSHConfig ¶
type SSHConfig struct { Host string // hostname of the SSH server Port int // port of the SSH server User string // username to login to the SSH server Password string // password of the user KeyFile string // path to the private key file Passphrase string // passphrase of the private key file Timeout time.Duration // Timeout is the maximum amount of time for the TCP connection to establish. ExeTimeout time.Duration // ExeTimeout is the maximum amount of time for the command to finish Proxy *SSHConfig // ssh proxy config }
SSHConfig is the configuration needed to establish SSH connection.
Click to show internal directories.
Click to hide internal directories.