Documentation ¶
Index ¶
- type Config
- type FileResult
- type SSH
- func (s *SSH) Connect() error
- func (s *SSH) DownloadFile(remoteFileName, localFileName string) FileResult
- func (ssh *SSH) FormatFileSize(s int64) (size string)
- func (s *SSH) GetSshConfig() *ssh.ClientConfig
- func (s *SSH) Run(command string) (string, error)
- func (ssh *SSH) Status() bool
- func (s *SSH) Sudo(command string) (string, error)
- func (s *SSH) UploadFile(localFileName, remoteFileName string) FileResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileResult ¶ added in v1.0.4
type FileResult struct { Status bool `yaml:"status" json:"status"` LocalFileName string `yaml:"local_file_name" json:"local_file_name"` LocalFileSize uint64 `yaml:"local_file_size" json:"local_file_size"` RemoteFileName string `yaml:"remote_file_name" json:"remote_file_name"` RemoteFileSize uint64 `yaml:"remote_file_size" json:"remote_file_size"` }
type SSH ¶
SSH SSH连接对象
func New ¶
func New() *SSH
New 创建SSH对象 @param host 主机地址 @param username 用户名 @param password 密码 @param port 端口号,默认22
func NewWithConfig ¶
func NewWithPublicKey ¶ added in v1.0.6
NewWithPublicKey 通过公钥的方式连接 @param user 主机用户名 @param host 主机IP地址或域名 @param port 主机SSH服务端口号,一般是22 @return s SSH连接对象 @return err 错误信息
func (*SSH) DownloadFile ¶ added in v1.0.0
func (s *SSH) DownloadFile(remoteFileName, localFileName string) FileResult
DownloadFile 下载文件
func (*SSH) FormatFileSize ¶ added in v1.0.4
FormatFileSize 字节的单位转换 保留两位小数
func (*SSH) GetSshConfig ¶ added in v1.0.4
func (s *SSH) GetSshConfig() *ssh.ClientConfig
GetSshConfig 获取SSH客户端配置
func (*SSH) UploadFile ¶ added in v1.0.0
func (s *SSH) UploadFile(localFileName, remoteFileName string) FileResult
UploadFile 上传文件
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package fs provides filesystem-related functions.
|
Package fs provides filesystem-related functions. |
Package sftp implements the SSH File Transfer Protocol as described in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
|
Package sftp implements the SSH File Transfer Protocol as described in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02 |
examples/buffered-read-benchmark
buffered-read-benchmark benchmarks the peformance of reading from /dev/zero on the server to a []byte on the client via io.Copy.
|
buffered-read-benchmark benchmarks the peformance of reading from /dev/zero on the server to a []byte on the client via io.Copy. |
examples/buffered-write-benchmark
buffered-write-benchmark benchmarks the peformance of writing a single large []byte on the client to /dev/null on the server via io.Copy.
|
buffered-write-benchmark benchmarks the peformance of writing a single large []byte on the client to /dev/null on the server via io.Copy. |
examples/go-sftp-server
An example SFTP server implementation using the golang SSH package.
|
An example SFTP server implementation using the golang SSH package. |
examples/request-server
An example SFTP server implementation using the golang SSH package.
|
An example SFTP server implementation using the golang SSH package. |
examples/streaming-read-benchmark
streaming-read-benchmark benchmarks the peformance of reading from /dev/zero on the server to /dev/null on the client via io.Copy.
|
streaming-read-benchmark benchmarks the peformance of reading from /dev/zero on the server to /dev/null on the client via io.Copy. |
examples/streaming-write-benchmark
streaming-write-benchmark benchmarks the peformance of writing from /dev/zero on the client to /dev/null on the server via io.Copy.
|
streaming-write-benchmark benchmarks the peformance of writing from /dev/zero on the client to /dev/null on the server via io.Copy. |
internal/encoding/ssh/filexfer
Package filexfer implements the wire encoding for secsh-filexfer as described in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02
|
Package filexfer implements the wire encoding for secsh-filexfer as described in https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02 |
internal/encoding/ssh/filexfer/openssh
Package openssh implements the openssh secsh-filexfer extensions as described in https://github.com/openssh/openssh-portable/blob/master/PROTOCOL
|
Package openssh implements the openssh secsh-filexfer extensions as described in https://github.com/openssh/openssh-portable/blob/master/PROTOCOL |
Click to show internal directories.
Click to hide internal directories.