wish

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: MIT Imports: 6 Imported by: 180

README

Wish


Latest Release GoDoc Build Status

Make SSH apps, just like that! 💫

SSH is an excellent platform to build remotely accessible applications on. It offers secure communication without the hassle of HTTPS certificates, it has user identification with SSH keys and it's accessible from anywhere with a terminal. Powerful protocols like Git work over SSH and you can even render TUIs directly over an SSH connection.

Wish is an SSH server with sensible defaults and a collection of middleware that makes building SSH apps easy. Wish is built on gliderlabs/ssh and should be easy to integrate into any existing projects.

Middleware

Bubble Tea

The bubbletea middleware makes it easy to serve any Bubble Tea application over SSH. Each SSH session will get their own tea.Program with the SSH pty input and output connected. Client window dimension and resize messages are also natively handled by the tea.Program.

You can see a demo of the Wish middleware in action at: ssh git.charm.sh

Git

The git middleware adds git server functionality to any ssh server. It supports repo creation on initial push and custom public key based auth.

This middleware requires that git is installed on the server.

Logging

The logging middleware provides basic connection logging. Connects are logged with the remote address, invoked command, TERM setting, window dimensions and if the auth was public key based. Disconnect will log the remote address and connection duration.

Access Control

Not all applications will support general SSH connections. To restrict access to supported methods, you can use the activeterm middleware to only allow connections with active terminals connected and the accesscontrol middleware that lets you specify allowed commands.

Default Server

Wish includes the ability to easily create an always authenticating default SSH server with automatic server key generation.

Examples

There are examples for a standalone Bubble Tea application and Git server in the examples folder. To see a more real-world application that combines Bubble Tea and Git, you can take a look at Soft Serve which uses Git as a CMS and provides a TUI over SSH for interacting with pushed repos.

Pro Tip

When building various Wish applications locally you can add the following to your ~/.ssh/config to avoid having to clear out localhost entries in your ~/.ssh/known_hosts file:

Host localhost
    UserKnownHostsFile /dev/null

License

MIT


Part of Charm.

The Charm logo

Charm热爱开源 • Charm loves open source

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 WithAddress

func WithAddress(addr string) ssh.Option

WithAddress returns an ssh.Option that sets the address to listen on.

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.

func WithIdleTimeout added in v0.1.2

func WithIdleTimeout(d time.Duration) ssh.Option

WithIdleTimeout returns an ssh.Option that sets the connection's idle timeout.

func WithMaxTimeout added in v0.1.2

func WithMaxTimeout(d time.Duration) ssh.Option

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 return a ssh.Option. This 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 WithVersion

func WithVersion(version string) ssh.Option

WithVersion returns an ssh.Option that sets the server version.

Types

type Middleware

type Middleware func(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.
examples
git
Package testsession provides utilities to test SSH sessions.
Package testsession provides utilities to test SSH sessions.

Jump to

Keyboard shortcuts

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