Movatterモバイル変換


[0]ホーム

URL:


agentssh

package
v2.23.0Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:40Imported by:1

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

View Source
const (// MagicSessionErrorCode indicates that something went wrong with the session, rather than the// command just returning a nonzero exit code, and is chosen as an arbitrary, high number// unlikely to shadow other exit codes, which are typically 1, 2, 3, etc.MagicSessionErrorCode = 229// MagicProcessCmdlineJetBrains is a string in a process's command line that// uniquely identifies it as JetBrains software.MagicProcessCmdlineJetBrains = "idea.vendor.name=JetBrains"// BlockedFileTransferErrorCode indicates that SSH server restricted the raw command from performing// the file transfer.BlockedFileTransferErrorCode    = 65// Error code: host not allowed to connectBlockedFileTransferErrorMessage = "File transfer has been disabled.")
View Source
const (// MagicSessionTypeEnvironmentVariable is used to track the purpose behind an SSH connection.// This is stripped from any commands being executed, and is counted towards connection stats.MagicSessionTypeEnvironmentVariable = "CODER_SSH_SESSION_TYPE"// ContainerEnvironmentVariable is used to specify the target container for an SSH connection.// This is stripped from any commands being executed.// Only available if CODER_AGENT_DEVCONTAINERS_ENABLE=true.ContainerEnvironmentVariable = "CODER_CONTAINER"// ContainerUserEnvironmentVariable is used to specify the container user for// an SSH connection.// Only available if CODER_AGENT_DEVCONTAINERS_ENABLE=true.ContainerUserEnvironmentVariable = "CODER_CONTAINER_USER")
View Source
const (// X11StartPort is the starting port for X11 forwarding, this is the// port used for "DISPLAY=localhost:0".X11StartPort = 6000// X11DefaultDisplayOffset is the default offset for X11 forwarding.X11DefaultDisplayOffset = 10)

Variables

View Source
var BlockedFileTransferCommands = []string{"nc", "rsync", "scp", "sftp"}

BlockedFileTransferCommands contains a list of restricted file transfer commands.

Functions

funcBicopy

func Bicopy(ctxcontext.Context, c1, c2io.ReadWriteCloser)

Bicopy copies all of the data between the two connections and will close themafter one or both of them are done writing. If the context is canceled, bothof the connections will be closed.

funcCoderSigneradded inv2.20.0

func CoderSigner(seedint64) (gossh.Signer,error)

CoderSigner generates a deterministic SSH signer based on the provided seed.It uses RSA with a key size of 2048 bits.

funcNewJetbrainsChannelWatcheradded inv2.5.0

func NewJetbrainsChannelWatcher(ctxssh.Context, loggerslog.Logger, reportConnection reportConnectionFunc, newChannelgossh.NewChannel, counter *atomic.Int64)gossh.NewChannel

Types

typeChannelOnCloseadded inv2.5.0

type ChannelOnClose struct {gossh.Channel// contains filtered or unexported fields}

func (*ChannelOnClose)Closeadded inv2.5.0

func (c *ChannelOnClose) Close()error

typeConfigadded inv2.9.0

type Config struct {// MaxTimeout sets the absolute connection timeout, none if empty. If set to// 3 seconds or more, keep alive will be used instead.MaxTimeouttime.Duration// MOTDFile returns the path to the message of the day file. If set, the// file will be displayed to the user upon login.MOTDFile func()string// ServiceBanner returns the configuration for the Coder service banner.AnnouncementBanners func() *[]codersdk.BannerConfig// UpdateEnv updates the environment variables for the command to be// executed. It can be used to add, modify or replace environment variables.UpdateEnv func(current []string) (updated []string, errerror)// WorkingDirectory sets the working directory for commands and defines// where users will land when they connect via SSH. Default is the home// directory of the user.WorkingDirectory func()string// X11DisplayOffset is the offset to add to the X11 display number.// Default is 10.X11DisplayOffset *int// BlockFileTransfer restricts use of file transfer applications.BlockFileTransferbool// ReportConnection.ReportConnection reportConnectionFunc// Experimental: allow connecting to running containers if// CODER_AGENT_DEVCONTAINERS_ENABLE=true.ExperimentalDevContainersEnabledbool}

Config sets configuration parameters for the agent SSH server.

typeConnStats

type ConnStats struct {Sessionsint64VSCodeint64JetBrainsint64}

typeJetbrainsChannelWatcheradded inv2.5.0

type JetbrainsChannelWatcher struct {gossh.NewChannel// contains filtered or unexported fields}

JetbrainsChannelWatcher is used to track JetBrains port forwarded (Gateway)channels. If the port forward is something other than JetBrains, this structis a noop.

func (*JetbrainsChannelWatcher)Acceptadded inv2.5.0

func (w *JetbrainsChannelWatcher) Accept() (gossh.Channel, <-chan *gossh.Request,error)

typeMagicSessionTypeadded inv2.20.0

type MagicSessionTypestring

MagicSessionType is a type that represents the type of session that is beingestablished.

const (// MagicSessionTypeUnknown means the session type could not be determined.MagicSessionTypeUnknownMagicSessionType = "unknown"// MagicSessionTypeSSH is the default session type.MagicSessionTypeSSHMagicSessionType = "ssh"// MagicSessionTypeVSCode is set in the SSH config by the VS Code extension to identify itself.MagicSessionTypeVSCodeMagicSessionType = "vscode"// MagicSessionTypeJetBrains is set in the SSH config by the JetBrains// extension to identify itself.MagicSessionTypeJetBrainsMagicSessionType = "jetbrains")

MagicSessionType enums.

typeServer

type Server struct {Execeragentexec.Execer// contains filtered or unexported fields}

funcNewServer

func NewServer(ctxcontext.Context, loggerslog.Logger, prometheusRegistry *prometheus.Registry, fsafero.Fs, execeragentexec.Execer, config *Config) (*Server,error)

func (*Server)Close

func (s *Server) Close()error

Close the server and all active connections. Server can be re-usedafter Close is done.

func (*Server)ConnStats

func (s *Server) ConnStats()ConnStats

func (*Server)CreateCommand

func (s *Server) CreateCommand(ctxcontext.Context, scriptstring, env []string, eiusershell.EnvInfoer) (*pty.Cmd,error)

CreateCommand processes raw command input with OpenSSH-like behavior.If the script provided is empty, it will default to the users shell.This injects environment variables specified by the user at launch too.The final argument is an interface that allows the caller to providealternative implementations for the dependencies of CreateCommand.This is useful when creating a command to be run in a separate environment(for example, a Docker container). Pass in nil to use the default.

func (*Server)Serve

func (s *Server) Serve(lnet.Listener) (retErrerror)

Serve starts the server to handle incoming connections on the provided listener.It returns an error if no host keys are set or if there is an issue accepting connections.

func (*Server)Shutdown

func (s *Server) Shutdown(ctxcontext.Context)error

Shutdown stops accepting new connections. The current implementationcalls Close() for simplicity instead of waiting for existingconnections to close. If the context times out, Shutdown will returnbut Close() may not have completed.

func (*Server)UpdateHostSigneradded inv2.20.0

func (s *Server) UpdateHostSigner(seedint64)error

UpdateHostSigner updates the host signer with a new key generated from the provided seed.If an existing host key exists with the same algorithm, it is overwritten

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp