Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sshclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,20 @@ func Dial(network, addr string, config *ssh.ClientConfig) (*Client, error) {
}, nil
}

// DialWithConnection starts a client connection using existing net.Conn.
func DialWithConnection(conn net.Conn, addr string, config *ssh.ClientConfig) (*Client, error) {
ncc, chans, reqs, err := ssh.NewClientConn(conn, addr, config)
if err != nil {
return nil, err
}

client := ssh.NewClient(ncc, chans, reqs)

return &Client{
client: client,
}, nil
}

// Close closes the underlying client network connection.
func (c *Client) Close() error {
return c.client.Close()
Expand Down