tailssh

package
v1.104.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: BSD-3-Clause Imports: 66 Imported by: 0

Documentation

Overview

Package tailssh is an SSH server integrated into Tailscale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v1.104.1

func Register()

Register installs tailssh's hooks and child process handlers. It is called from the init of github.com/Xinlong-Wu/tailscale-oh/feature/ssh, which skips it if the ssh feature was disabled via TS_DISABLE_FEATURE or omitted from the build.

Types

type Pty

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

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

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

func (s *Session) Close() error

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

func (*Session) Context

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

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

func (*Session) Environ

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

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

func (*Session) Exit

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

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

func (*Session) LocalAddr

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

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

func (*Session) Peer

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

Peer returns the Tailscale identity of the remote node.

func (*Session) Pty

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

func (s *Session) RawCommand() string

RawCommand returns the exact command string provided by the client.

func (*Session) Read

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

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

func (*Session) RemoteAddr

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

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

func (*Session) SetDeadline

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

SetDeadline is not supported and returns an error.

func (*Session) SetReadDeadline

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

SetReadDeadline is not supported and returns an error.

func (*Session) SetWriteDeadline

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

SetWriteDeadline is not supported and returns an error.

func (*Session) Signals

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

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

func (*Session) Stderr

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

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

func (*Session) Subsystem

func (s *Session) Subsystem() string

Subsystem returns the subsystem requested by the client.

func (*Session) User

func (s *Session) User() string

User returns the SSH username.

func (*Session) UserProfile

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

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

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

type Signal

type Signal = gliderssh.Signal

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

type Window

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
⌂ 换网址