Initial import
This commit is contained in:
28
ssh/client.go
Normal file
28
ssh/client.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package ssh
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
netConn net.Conn
|
||||
client *ssh.Client
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
ssh.ClientConfig
|
||||
}
|
||||
|
||||
func NewClient(conn net.Conn, config *ClientConfig) (*Client, error) {
|
||||
sshConn, channels, requests, err := ssh.NewClientConn(conn, conn.RemoteAddr().String(), &config.ClientConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{
|
||||
netConn: conn,
|
||||
client: ssh.NewClient(sshConn, channels, requests),
|
||||
}, nil
|
||||
}
|
Reference in New Issue
Block a user