Documentation ¶
Index ¶
- func NewSshClient(cred *SshCredential) (*ssh.Client, error)
- func NewTelnetClient(cred *TelnetCredential) (*telnet.Client, error)
- type CmdShell
- type CmdShellConfig
- type SshCredential
- type SshShell
- func (this *SshShell) Client() *ssh.Client
- func (this *SshShell) Close() (err error)
- func (this *SshShell) HeadLine() []string
- func (this *SshShell) Session() *ssh.Session
- func (this *SshShell) Sftp(opt ...sftp.ClientOption) (*sftp.Client, error)
- func (this *SshShell) SftpDown(remotePath, localPath string, force bool) error
- func (this *SshShell) SftpRemove(path string) error
- func (this *SshShell) SftpUpload(localPath, remotePath string, force bool) error
- type SshShellConfig
- type TelnetCredential
- type TelnetShell
- type TelnetShellConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSshClient ¶
func NewSshClient(cred *SshCredential) (*ssh.Client, error)
NewSshClient 创建一个新的 SshClient
func NewTelnetClient ¶
func NewTelnetClient(cred *TelnetCredential) (*telnet.Client, error)
Types ¶
type CmdShell ¶
type CmdShell struct { *core.ReadWriter // contains filtered or unexported fields }
func NewCmdShell ¶
func NewCmdShell(cmdAndArgs string, config ...*CmdShellConfig) *CmdShell
type CmdShellConfig ¶
func (*CmdShellConfig) EnsureInit ¶
func (c *CmdShellConfig) EnsureInit()
type SshCredential ¶
type SshCredential struct { Host string `json:"host"` // IP地址 Port int `json:"port,omitempty"` // 端口,默认22 User string `json:"user,omitempty"` // 用户名 Password string `json:"password,omitempty"` // 密码。当密钥与密码同时存在时,优先使用密钥。 PrivateKey string `json:"private_key,omitempty"` // 密钥。当密钥与密码同时存在时,优先使用密钥。 Timeout int `json:"timeout,omitempty"` // 连接超时时间(秒),默认15秒 InsecureAlgorithms bool `json:"insecure_algorithms,omitempty"` // 是否允许不安全的算法 Fingerprint string `json:"fingerprint,omitempty"` // 公钥指纹,用于验证服务器身份 }
type SshShell ¶
type SshShell struct { *core.ReadWriter // contains filtered or unexported fields }
func NewSshShell ¶
func NewSshShell(config ...*SshShellConfig) (*SshShell, error)
func NewSshShellFromClient ¶
func NewSshShellFromClient(client *ssh.Client, config ...*SshShellConfig) (*SshShell, error)
func (*SshShell) SftpRemove ¶
SftpRemove 删除远程文件、目录,如果是目录,则递归删除目录及子目录下的所有文件
type SshShellConfig ¶
type SshShellConfig struct { core.Config Credential *SshCredential // 凭证 Echo bool // 模拟终端回显,默认值 false,部分网络设备上无效(总是回显) Term string // 模拟终端类型,默认值 VT100 TermHeight int // 模拟终端高度,默认值 200 TermWidth int // 模拟终端宽度,默认值 80 }
func (*SshShellConfig) EnsureInit ¶
func (c *SshShellConfig) EnsureInit()
type TelnetCredential ¶
type TelnetShell ¶
type TelnetShell struct { *core.ReadWriter // contains filtered or unexported fields }
func NewTelnetShell ¶
func NewTelnetShell(config ...*TelnetShellConfig) (*TelnetShell, error)
func NewTelnetShellFromClient ¶
func NewTelnetShellFromClient(client *telnet.Client, config ...*TelnetShellConfig) (*TelnetShell, error)
func (*TelnetShell) Client ¶
func (this *TelnetShell) Client() *telnet.Client
func (*TelnetShell) Close ¶
func (this *TelnetShell) Close() (err error)
func (*TelnetShell) HeadLine ¶
func (this *TelnetShell) HeadLine() []string
type TelnetShellConfig ¶
type TelnetShellConfig struct { core.Config Credential *TelnetCredential }
func (*TelnetShellConfig) EnsureInit ¶
func (c *TelnetShellConfig) EnsureInit()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.