ssh

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSshClient

func NewSshClient(user, password string, port string) (*ssh.Client, error)

func ReceiveWsMsgPassword

func ReceiveWsMsgPassword(wsConn *websocket.Conn, logBuff *bytes.Buffer) string

func ReceiveWsMsgUser

func ReceiveWsMsgUser(wsConn *websocket.Conn, logBuff *bytes.Buffer) string

ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin

func WsReaderCopy

func WsReaderCopy(reader *websocket.Conn, writer io.Writer)

将前端的输入转发到终端

func WsWriterCopy

func WsWriterCopy(reader io.Reader, writer *websocket.Conn)

将终端的输出转发到前端

Types

type SshConn

type SshConn struct {
	// calling Write() to write data into ssh server
	StdinPipe io.WriteCloser
	// Write() be called to receive data from ssh server
	ComboOutput *wsBufferWriter
	Session     *ssh.Session
}

func NewSshConn

func NewSshConn(cols, rows int, sshClient *ssh.Client) (*SshConn, error)

setup ssh shell session set Session and StdinPipe here, and the Session.Stdout and Session.Sdterr are also set.

func (*SshConn) Close

func (s *SshConn) Close()

func (*SshConn) Login

func (ssConn *SshConn) Login(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool)

ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin

func (*SshConn) ReceiveWsMsg

func (ssConn *SshConn) ReceiveWsMsg(wsConn *websocket.Conn, logBuff *bytes.Buffer, exitCh chan bool)

ReceiveWsMsg receive websocket msg do some handling then write into ssh.session.stdin

func (*SshConn) SendComboOutput

func (ssConn *SshConn) SendComboOutput(wsConn *websocket.Conn, exitCh chan bool)

func (*SshConn) SessionWait

func (ssConn *SshConn) SessionWait(quitChan chan bool)

Jump to

Keyboard shortcuts

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