tailssh

package
v1.100.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: BSD-3-Clause Imports: 65 Imported by: 6

Documentation

Overview

Package tailssh is an SSH server integrated into Tailscale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pty added in v1.100.0

type Pty struct {
	// Term is the TERM environment variable value.
	Term string

	// Window is the initial window size.
	Window Window

	// Modes are the RFC 4254 terminal modes as opcode/value pairs.
	Modes map[uint8]uint32
}

Pty represents a PTY request and configuration.

type SSHTerminationError added in v1.24.0

type SSHTerminationError interface {
	error
	SSHTerminationMessage() string
}

SSHTerminationError is implemented by errors that terminate an SSH session and should be written to user's sessions.

type Session added in v1.100.0

type Session struct {
	// contains filtered or unexported fields
}

Session wraps a gliderlabs gliderssh.Session with Tailscale peer identity information. It implements net.Conn so callers that only need Read/Write/Close can use it directly. Callers that need SSH-specific functionality can type-assert from the net.Conn returned by the listener's Accept.

func (*Session) Close added in v1.100.0

func (s *Session) Close() error

Close signals the session handler to return and closes the underlying channel.

func (*Session) Context added in v1.100.0

func (s *Session) Context() context.Context

Context returns the session's context, which is canceled when the client disconnects.

func (*Session) Environ added in v1.100.0

func (s *Session) Environ() []string

Environ returns a copy of the environment variables set by the client.

func (*Session) Exit added in v1.100.0

func (s *Session) Exit(code int) error

Exit sends an exit status to the client and closes the session.

func (*Session) LocalAddr added in v1.100.0

func (s *Session) LocalAddr() net.Addr

LocalAddr returns the net.Addr of the server side of the connection.

func (*Session) Peer added in v1.100.0

func (s *Session) Peer() tailcfg.NodeView

Peer returns the Tailscale identity of the remote node.

func (*Session) Pty added in v1.100.0

func (s *Session) Pty() (_ Pty, _ <-chan Window, ok bool)

Pty returns PTY information, a channel of window size changes, and whether a PTY was requested.

func (*Session) RawCommand added in v1.100.0

func (s *Session) RawCommand() string

RawCommand returns the exact command string provided by the client.

func (*Session) Read added in v1.100.0

func (s *Session) Read(p []byte) (int, error)

Read reads from the SSH channel (stdin from the client).

func (*Session) RemoteAddr added in v1.100.0

func (s *Session) RemoteAddr() net.Addr

RemoteAddr returns the net.Addr of the client side of the connection.

func (*Session) SetDeadline added in v1.100.0

func (s *Session) SetDeadline(t time.Time) error

SetDeadline is not supported and returns an error.

func (*Session) SetReadDeadline added in v1.100.0

func (s *Session) SetReadDeadline(t time.Time) error

SetReadDeadline is not supported and returns an error.

func (*Session) SetWriteDeadline added in v1.100.0

func (s *Session) SetWriteDeadline(t time.Time) error

SetWriteDeadline is not supported and returns an error.

func (*Session) Signals added in v1.100.0

func (s *Session) Signals(c chan<- Signal)

Signals registers a channel to receive signals from the client. Pass nil to unregister.

func (*Session) Stderr added in v1.100.0

func (s *Session) Stderr() io.Writer

Stderr returns an io.Writer for the SSH stderr channel.

func (*Session) Subsystem added in v1.100.0

func (s *Session) Subsystem() string

Subsystem returns the subsystem requested by the client.

func (*Session) User added in v1.100.0

func (s *Session) User() string

User returns the SSH username.

func (*Session) UserProfile added in v1.100.0

func (s *Session) UserProfile() tailcfg.UserProfile

UserProfile returns the Tailscale user profile of the remote node.

For tagged nodes, this is same sort of UserProfile that is returned by the LocalAPI WhoIs API.

func (*Session) Write added in v1.100.0

func (s *Session) Write(p []byte) (int, error)

Write writes to the SSH channel (stdout to the client).

type Signal added in v1.100.0

type Signal = gliderssh.Signal

Signal represents an SSH signal (e.g. "INT", "TERM").

type Window added in v1.100.0

type Window struct {
	Width        int // columns
	Height       int // rows
	WidthPixels  int // width in pixels
	HeightPixels int // height in pixels
}

Window represents the size of a PTY window.

Jump to

Keyboard shortcuts

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