Documentation
¶
Index ¶
- Constants
- Variables
- func NewClientConn(session *Session) net.Conn
- func NewConn(conn net.Conn, channel ssh.Channel) net.Conn
- func NewHostKeyCallback(knownHostsFile, hostKey string, insecure bool) (ssh.HostKeyCallback, error)
- func ParseAuthorizedKeysFile(name string) (map[string]bool, error)
- type ClientConn
- type PasswordCallbackFunc
- type PublicKeyCallbackFunc
- type Session
- func (s *Session) IsClosed() bool
- func (s *Session) Keepalive(interval, timeout time.Duration, retries int)
- func (s *Session) OpenChannel(name string) (ssh.Channel, <-chan *ssh.Request, error)
- func (s *Session) Ping(timeout time.Duration) error
- func (s *Session) Wait() error
- func (s *Session) WaitClose()
Constants ¶
const (
TnetSSHTunnelRequest = "tnet-tunnel" // extended request type for ssh tunnel
)
Variables ¶
var ErrNoHostKey = errors.New("ssh: no trusted host key configured: " +
"set hostKeyFile or hostKey, or set insecureSkipHostKeyVerify=true to disable verification")
ErrNoHostKey is returned when no trusted host key was configured and no default known_hosts file is available. Dialers fail closed on this error instead of connecting to an unauthenticated server.
var (
ErrSessionDead = errors.New("session is dead")
)
Functions ¶
func NewClientConn ¶
func NewHostKeyCallback ¶ added in v0.28.1
func NewHostKeyCallback(knownHostsFile, hostKey string, insecure bool) (ssh.HostKeyCallback, error)
NewHostKeyCallback builds the HostKeyCallback used by the ssh and sshd dialers.
insecure accept any host key. This was the previous behavior
and is now an explicit opt-in.
hostKey != "" pin a single key, given either as an authorized_keys
line ("ssh-ed25519 AAAA...") or as a SHA256:/MD5:
fingerprint.
knownHostsFile != "" verify against that known_hosts file.
When none of them is set, ~/.ssh/known_hosts is used if it exists. If there is no usable known_hosts file the function returns ErrNoHostKey so that the dialer refuses to connect.
Types ¶
type ClientConn ¶
a dummy ssh client conn used by client connector
func (*ClientConn) Client ¶
func (c *ClientConn) Client() *ssh.Client
type PasswordCallbackFunc ¶
type PasswordCallbackFunc func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)
PasswordCallbackFunc is a callback function used by SSH server. It authenticates user using a password.
func PasswordCallback ¶
func PasswordCallback(service string, au auth.Authenticator) PasswordCallbackFunc
type PublicKeyCallbackFunc ¶
type PublicKeyCallbackFunc func(c ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error)
PublicKeyCallbackFunc is a callback function used by SSH server. It offers a public key for authentication.
func PublicKeyCallback ¶
func PublicKeyCallback(keys map[string]bool) PublicKeyCallbackFunc