Documentation
¶
Index ¶
- Constants
- func AddKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) error
- func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (bool, error)
- func Conn(c *Client, cfg *ssh.ClientConfig) (err error)
- func DefaultKnownHosts() (ssh.HostKeyCallback, error)
- func Download(c *ssh.Client, src string, dest string) (err error)
- func GetSigner(prvFile string, passphrase string) (ssh.Signer, error)
- func KnownHosts(file string) (ssh.HostKeyCallback, error)
- func Upload(c *ssh.Client, src string, dest string) (err error)
- type Auth
- type Client
- func (t Client) BindTunnel(ctx context.Context, wg *sync.WaitGroup)
- func (c Client) Close() error
- func (t Client) DialTunnel(ctx context.Context, wg *sync.WaitGroup, client *ssh.Client, cn1 net.Conn)
- func (c Client) Download(remotePath string, localPath string) error
- func (client *Client) Interact() error
- func (c Client) NewSession() (*ssh.Session, error)
- func (c Client) Run(cmd string) ([]byte, error)
- func (c Client) Upload(localPath string, remotePath string) error
- type Interactive
Constants ¶
const ( UDP string = "udp" TCP string = "tcp" )
Variables ¶
This section is empty.
Functions ¶
func AddKnownHost ¶
Add a host to knows hosts this function by @dixonwille see: https://github.com/melbahja/goph/issues/2
func CheckKnownHost ¶
func CheckKnownHost(host string, remote net.Addr, key ssh.PublicKey, knownFile string) (bool, error)
Check is host in known hosts file. It returns is the host found in known_hosts file and error, If the host found in known_hosts file and error not nil that means public key mismatch, Maybe MAN IN THE MIDDLE ATTACK! you should not handshake.
func Conn ¶
func Conn(c *Client, cfg *ssh.ClientConfig) (err error)
Set new net connection to a client.
func DefaultKnownHosts ¶
func DefaultKnownHosts() (ssh.HostKeyCallback, error)
Use default known hosts files to verify host public key.
func KnownHosts ¶
func KnownHosts(file string) (ssh.HostKeyCallback, error)
Get known hosts callback from a custom path.
Types ¶
type Auth ¶
type Auth []ssh.AuthMethod
type Client ¶
type Client struct { *sshtunnel.Tunnel *Interactive Auth }
func NewConn ¶
func NewConn(user string, addr string, auth Auth, callback ssh.HostKeyCallback) (c *Client, err error)
Get new client connection.
func NewUnknown ¶
Connect to ssh and get client without cheking knownhosts. PLEASE AVOID USING THIS, UNLESS YOU KNOW WHAT ARE YOU DOING! if there a "man in the middle proxy", this can harm you! You can add the key to know hosts and use New() func instead!
func (Client) DialTunnel ¶
func (Client) NewSession ¶
Get new ssh session from client connection See: https://pkg.go.dev/golang.org/x/crypto/ssh?tab=doc#Session