ssh

package
v0.28.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TnetSSHTunnelRequest = "tnet-tunnel" // extended request type for ssh tunnel
)

Variables

View Source
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.

View Source
var (
	ErrSessionDead = errors.New("session is dead")
)

Functions

func NewClientConn

func NewClientConn(session *Session) net.Conn

func NewConn

func NewConn(conn net.Conn, channel ssh.Channel) net.Conn

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.

func ParseAuthorizedKeysFile

func ParseAuthorizedKeysFile(name string) (map[string]bool, error)

ParseSSHAuthorizedKeysFile parses ssh authorized keys file.

Types

type ClientConn

type ClientConn struct {
	net.Conn
	// contains filtered or unexported fields
}

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

type Session

type Session struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewSession

func NewSession(c net.Conn, client *ssh.Client, log logger.Logger) *Session

func (*Session) IsClosed

func (s *Session) IsClosed() bool

func (*Session) Keepalive

func (s *Session) Keepalive(interval, timeout time.Duration, retries int)

func (*Session) OpenChannel

func (s *Session) OpenChannel(name string) (ssh.Channel, <-chan *ssh.Request, error)

func (*Session) Ping added in v0.28.1

func (s *Session) Ping(timeout time.Duration) error

Ping checks if the SSH session is alive by sending a keepalive request. It blocks until a response is received or the timeout expires. A nil error indicates the session is healthy.

func (*Session) Wait

func (s *Session) Wait() error

func (*Session) WaitClose

func (s *Session) WaitClose()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL