ssh

package
v0.0.0-...-d741a62 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EcsSSH

type EcsSSH struct {
	IP       string      // IP地址
	Port     int         // 端口号
	Username string      // 用户名
	Mode     string      // 认证方式[password:密码,key:秘钥认证]
	Password string      // 密码
	Key      string      // 认证私钥
	Client   *ssh.Client // ssh客户端
	UserID   int         // 用户ID
	// console
	Sessions   map[int]*ssh.Session // ssh会话对象
	Channel    ssh.Channel          // ssh通信管道
	LastResult string               // 最近一次执行命令的结果
	// contains filtered or unexported fields
}

func NewSSH

func NewSSH(l *zap.Logger) *EcsSSH

func (*EcsSSH) AddPublicKeyToRemoteHost

func (s *EcsSSH) AddPublicKeyToRemoteHost(publicKey string) error

AddPublicKeyToRemoteHost 将公钥写入目标主机

func (*EcsSSH) Connect

func (s *EcsSSH) Connect(ip string, port int, username string, password string, key string, mode string, userID int) error

Connect SSH连接

func (*EcsSSH) Run

func (s *EcsSSH) Run(command string) (string, error)

Run 执行Shell命令

func (*EcsSSH) Web2SSH

func (s *EcsSSH) Web2SSH(ws *websocket.Conn)

Web2SSH 实现Web SSH功能

type MyReader

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

func (MyReader) Read

func (r MyReader) Read(p []byte) (n int, err error)

MyReader 从WebSocket读取数据

type MyWriter

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

func (MyWriter) Write

func (w MyWriter) Write(p []byte) (n int, err error)

MyWriter 向WebSocket写入数据

Jump to

Keyboard shortcuts

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