Documentation
¶
Index ¶
Constants ¶
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 // 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" // MagicSessionTypeVSCode is set in the SSH config by the VS Code extension to identify itself. MagicSessionTypeVSCode = "vscode" // MagicSessionTypeJetBrains is set in the SSH config by the JetBrains // extension to identify itself. MagicSessionTypeJetBrains = "jetbrains" // 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 connect BlockedFileTransferErrorMessage = "File transfer has been disabled." )
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 ¶
var BlockedFileTransferCommands = []string{"nc", "rsync", "scp", "sftp"}
BlockedFileTransferCommands contains a list of restricted file transfer commands.
Functions ¶
func Bicopy ¶
func Bicopy(ctx context.Context, c1, c2 io.ReadWriteCloser)
Bicopy copies all of the data between the two connections and will close them after one or both of them are done writing. If the context is canceled, both of the connections will be closed.
func NewJetbrainsChannelWatcher ¶ added in v2.5.0
func NewJetbrainsChannelWatcher(ctx ssh.Context, logger slog.Logger, newChannel gossh.NewChannel, counter *atomic.Int64) gossh.NewChannel
Types ¶
type ChannelOnClose ¶ added in v2.5.0
func (*ChannelOnClose) Close ¶ added in v2.5.0
func (c *ChannelOnClose) Close() error
type Config ¶ added in v2.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. MaxTimeout time.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, err error) // 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. BlockFileTransfer bool }
Config sets configuration parameters for the agent SSH server.
type JetbrainsChannelWatcher ¶ added in v2.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 struct is a noop.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Close ¶
Close the server and all active connections. Server can be re-used after Close is done.
func (*Server) CreateCommand ¶
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.