Documentation ¶
Index ¶
- func Error(s ssh.Session, v ...interface{})
- func Errorf(s ssh.Session, f string, v ...interface{})
- func Errorln(s ssh.Session, v ...interface{})
- func Fatal(s ssh.Session, v ...interface{})
- func Fatalf(s ssh.Session, f string, v ...interface{})
- func Fatalln(s ssh.Session, v ...interface{})
- func NewServer(ops ...ssh.Option) (*ssh.Server, error)
- func Print(s ssh.Session, v ...interface{})
- func Printf(s ssh.Session, f string, v ...interface{})
- func Println(s ssh.Session, v ...interface{})
- func WithAddress(addr string) ssh.Option
- func WithAuthorizedKeys(path string) ssh.Option
- func WithBanner(banner string) ssh.Option
- func WithBannerHandler(h ssh.BannerHandler) ssh.Option
- func WithHostKeyPEM(pem []byte) ssh.Option
- func WithHostKeyPath(path string) ssh.Option
- func WithIdleTimeout(d time.Duration) ssh.Option
- func WithKeyboardInteractiveAuth(h ssh.KeyboardInteractiveHandler) ssh.Option
- func WithMaxTimeout(d time.Duration) ssh.Option
- func WithMiddleware(mw ...Middleware) ssh.Option
- func WithPasswordAuth(p ssh.PasswordHandler) ssh.Option
- func WithPublicKeyAuth(h ssh.PublicKeyHandler) ssh.Option
- func WithSubsystem(key string, h ssh.SubsystemHandler) ssh.Option
- func WithTrustedUserCAKeys(path string) ssh.Option
- func WithVersion(version string) ssh.Option
- func WriteString(s ssh.Session, v string) (int, error)
- type Cmd
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(s ssh.Session, v ...interface{})
Error prints the given error the the session's STDERR.
func Errorf ¶
func Errorf(s ssh.Session, f string, v ...interface{})
Errorf formats according to the given format and prints to the session's STDERR.
func Errorln ¶
func Errorln(s ssh.Session, v ...interface{})
Errorf formats according to the default format and prints to the session's STDERR.
func Fatal ¶
func Fatal(s ssh.Session, v ...interface{})
Fatal prints to the given session's STDERR and exits 1.
func Fatalf ¶
func Fatalf(s ssh.Session, f string, v ...interface{})
Fatalf formats according to the given format, prints to the session's STDERR followed by an exit 1.
Notice that this might cause formatting issues if you don't add a \r\n in the end of your string.
func Fatalln ¶
func Fatalln(s ssh.Session, v ...interface{})
Fatalln formats according to the default format, prints to the session's STDERR, followed by a new line and an exit 1.
func NewServer ¶
func NewServer(ops ...ssh.Option) (*ssh.Server, error)
NewServer is returns a default SSH server with the provided Middleware. A new SSH key pair of type ed25519 will be created if one does not exist. By default this server will accept all incoming connections, password and public key.
func Print ¶
func Print(s ssh.Session, v ...interface{})
Print writes to the session's STDOUT followed.
func Printf ¶
func Printf(s ssh.Session, f string, v ...interface{})
Printf formats according to the given format and writes to the session's STDOUT.
func Println ¶
func Println(s ssh.Session, v ...interface{})
Println formats according to the default format and writes to the session's STDOUT.
func WithAddress ¶
func WithAddress(addr string) ssh.Option
WithAddress returns an ssh.Option that sets the address to listen on.
func WithAuthorizedKeys ¶
func WithAuthorizedKeys(path string) ssh.Option
WithAuthorizedKeys allows the use of an SSH authorized_keys file to allowlist users.
func WithBanner ¶
func WithBanner(banner string) ssh.Option
WithBanner return an ssh.Option that sets the server banner.
func WithBannerHandler ¶
func WithBannerHandler(h ssh.BannerHandler) ssh.Option
WithBannerHandler return an ssh.Option that sets the server banner handler, overriding WithBanner.
func WithHostKeyPEM ¶
func WithHostKeyPEM(pem []byte) ssh.Option
WithHostKeyPEM returns an ssh.Option that sets the host key from a PEM block.
func WithHostKeyPath ¶
func WithHostKeyPath(path string) ssh.Option
WithHostKeyFile returns an ssh.Option that sets the path to the private key.
func WithIdleTimeout ¶
WithIdleTimeout returns an ssh.Option that sets the connection's idle timeout.
func WithKeyboardInteractiveAuth ¶
func WithKeyboardInteractiveAuth(h ssh.KeyboardInteractiveHandler) ssh.Option
WithKeyboardInteractiveAuth returns an ssh.Option that sets the keyboard interactive auth handler.
func WithMaxTimeout ¶
WithMaxTimeout returns an ssh.Option that sets the connection's absolute timeout.
func WithMiddleware ¶
func WithMiddleware(mw ...Middleware) ssh.Option
WithMiddleware composes the provided Middleware and returns an ssh.Option. This is useful if you manually create an ssh.Server and want to set the Server.Handler.
Notice that middlewares are composed from first to last, which means the last one is executed first.
func WithPasswordAuth ¶
func WithPasswordAuth(p ssh.PasswordHandler) ssh.Option
WithPasswordAuth returns an ssh.Option that sets the password auth handler.
func WithPublicKeyAuth ¶
func WithPublicKeyAuth(h ssh.PublicKeyHandler) ssh.Option
WithPublicKeyAuth returns an ssh.Option that sets the public key auth handler.
func WithSubsystem ¶
func WithSubsystem(key string, h ssh.SubsystemHandler) ssh.Option
WithSubsystem returns an ssh.Option that sets the subsystem handler for a given protocol.
func WithTrustedUserCAKeys ¶
func WithTrustedUserCAKeys(path string) ssh.Option
WithTrustedUserCAKeys authorize certificates that are signed with the given Certificate Authority public key, and are valid. Analogous to the TrustedUserCAKeys OpenSSH option.
func WithVersion ¶
func WithVersion(version string) ssh.Option
WithVersion returns an ssh.Option that sets the server version.
func WriteString ¶
WriteString writes the given string to the session's STDOUT.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd wraps a *exec.Cmd and a ssh.Pty so a command can be properly run.
func Command ¶
Command sets stdin, stdout, and stderr to the current session's PTY.
If the current session does not have a PTY, it sets them to the session itself.
This will use the session's context as the context for exec.Command.
func CommandContext ¶
CommandContext is like Command but includes a context.
If the current session does not have a PTY, it sets them to the session itself.
type Middleware ¶
type Middleware func(next ssh.Handler) ssh.Handler
Middleware is a function that takes an ssh.Handler and returns an ssh.Handler. Implementations should call the provided handler argument.
Directories ¶
Path | Synopsis |
---|---|
Package accesscontrol provides a middleware that allows you to restrict the commands the user can execute.
|
Package accesscontrol provides a middleware that allows you to restrict the commands the user can execute. |
Package activeterm provides a middleware to block inactive PTYs.
|
Package activeterm provides a middleware to block inactive PTYs. |
Package bubbletea provides middleware for serving bubbletea apps over SSH.
|
Package bubbletea provides middleware for serving bubbletea apps over SSH. |
Package ratelimiter provides basic rate limiting functionality as a with middleware.
|
Package ratelimiter provides basic rate limiting functionality as a with middleware. |
Package scp provides a SCP middleware for wish.
|
Package scp provides a SCP middleware for wish. |
Package testsession provides utilities to test SSH sessions.
|
Package testsession provides utilities to test SSH sessions. |