ssh

package
v1.0.73 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(user, password, addr string) (client *ssh.Client, err error)

创建ssh客户端

func Command

func Command(remote, password, cmd string) (output string, err error)

执行命令

func CommandSession

func CommandSession(session *ssh.Session, cmd string) (output string, err error)

会话执行命令

func Scp

func Scp(local, remote, password string, fn func(current, total int64)) (err error)

文件拷贝

func ScpReader

func ScpReader(client *sftp.Client, filename string, reader io.Reader) (err error)

数据拷贝

func Session

func Session(user, password, addr string) (client *ssh.Client, session *ssh.Session, err error)

创建ssh客户端与会话

func SftpClient

func SftpClient(user, password, addr string) (client *sftp.Client, err error)

创建sftp客户端

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func NewPool

func NewPool(min, max int, idle time.Duration) *Pool

func (*Pool) Add

func (p *Pool) Add(addr, user, password string)

func (*Pool) Close

func (p *Pool) Close() error

func (*Pool) Command

func (p *Pool) Command(remote, password, cmd string) (output string, err error)

func (*Pool) Init

func (p *Pool) Init(remote ...Remote)

func (*Pool) Scp

func (p *Pool) Scp(local, remote, password string, fn func(current, total int64)) (err error)

func (*Pool) ScpReader

func (p *Pool) ScpReader(reader io.Reader, remote, password string, fn func(size int)) (err error)

func (*Pool) Session

func (p *Pool) Session(addr, user, password string) (session *ssh.Session, err error)

func (*Pool) SftpClient

func (p *Pool) SftpClient(addr, user, password string) (client *sftp.Client, err error)

type Pool2

type Pool2 struct {
	// contains filtered or unexported fields
}

func NewPool2

func NewPool2(min, max int, idle time.Duration) *Pool2

func (*Pool2) Command

func (p *Pool2) Command(remote, password, cmd string) (output string, err error)

func (*Pool2) Scp

func (p *Pool2) Scp(local, remote, password string, fn func(current, total int64)) (err error)

func (*Pool2) ScpReader

func (p *Pool2) ScpReader(reader io.Reader, remote, password string, fn func(size int)) (err error)

func (*Pool2) Session

func (p *Pool2) Session(addr, username, password string) (session *ssh.Session, err error)

func (*Pool2) SftpClient

func (p *Pool2) SftpClient(addr, username, password string) (*sftp.Client, error)

type PoolOption

type PoolOption struct {
	MaxConn int
	MinConn int
}

type Remote

type Remote struct {
	Addr     string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL