Files
conduit/ssh/client.go
2025-10-10 10:05:28 +02:00

29 lines
491 B
Go

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
}