• Stars
    star
    2,816
  • Rank 15,493 (Top 0.4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make SSH apps, just like that! ๐Ÿ’ซ

Wish

A nice rendering of a star, anthropomorphized somewhat by means of a smile, with the words โ€˜Charm Wishโ€™ next to it
Latest Release GoDoc Build Status Codecov branch Go Report Card

Make SSH apps, just like that! ๐Ÿ’ซ

SSH is an excellent platform for building remotely accessible applications. It offers:

  • secure communication without the hassle of HTTPS certificates
  • user identification with SSH keys
  • access from any 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 middlewares that makes building SSH apps really easy. Wish is built on gliderlabs/ssh and should be easy to integrate into any existing projects.

What are SSH Apps?

Usually, when we think about SSH, we think about remote shell access into servers, most commonly through openssh-server.

That's a perfectly valid (and probably the most common) use of SSH, but it can do so much more than that. Just like HTTP, SMTP, FTP and others, SSH is a protocol! It is a cryptographic network protocol for operating network services securely over an unsecured network. 1

That means, among other things, that we can write custom SSH servers without touching openssh-server, so we can securely do more things than just providing a shell.

Wish is a library that helps writing these kind of apps using Go.

Middleware

Wish middlewares are analogous to those in several HTTP frameworks. They are essentially SSH handlers that you can use to do specific tasks, and then call the next middleware.

Notice that middlewares are composed from first to last, which means the last one is executed first.

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.

Apps Built With Wish

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

How it works?

Wish uses gliderlabs/ssh to implement its SSH server, and OpenSSH is never used nor needed โ€” you can even uninstall it if you want to.

Incidentally, there's no risk of accidentally sharing a shell because there's no default behavior that does that on Wish.

Running with SystemD

If you want to run a Wish app with systemd, you can create an unit like so:

/etc/systemd/system/myapp.service:

[Unit]
Description=My App
After=network.target

[Service]
Type=simple
User=myapp
Group=myapp
WorkingDirectory=/home/myapp/
ExecStart=/usr/bin/myapp
Restart=on-failure

[Install]
WantedBy=multi-user.target

You can tune the values below, and once you're happy with them, you can run:

# need to run this every time you change the unit file
sudo systemctl daemon-reload

# start/restart/stop/etc:
sudo systemctl start myapp

If you use a new user for each app (which is good), you'll need to create them first:

useradd --system --user-group --create-home myapp

That should do it.

Feedback

Weโ€™d love to hear your thoughts on this project. Feel free to drop us a note!

License

MIT


Part of Charm.

The Charm logo

Charm็ƒญ็ˆฑๅผ€ๆบ โ€ข Charm loves open source

Footnotes

  1. https://en.wikipedia.org/wiki/Secure_Shell โ†ฉ

More Repositories

1

bubbletea

A powerful little TUI framework ๐Ÿ—
Go
23,251
star
2

gum

A tool for glamorous shell scripts ๐ŸŽ€
Go
16,385
star
3

glow

Render markdown on the CLI, with pizzazz! ๐Ÿ’…๐Ÿป
Go
14,499
star
4

vhs

Your CLI home video recorder ๐Ÿ“ผ
Go
13,375
star
5

lipgloss

Style definitions for nice terminal layouts ๐Ÿ‘„
Go
7,073
star
6

soft-serve

The mighty, self-hostable Git server for the command line๐Ÿฆ
Go
4,638
star
7

bubbles

TUI components for Bubble Tea ๐Ÿซง
Go
4,509
star
8

huh

Build terminal forms and prompts ๐Ÿคท๐Ÿปโ€โ™€๏ธ
Go
2,956
star
9

mods

AI on the command line
Go
2,261
star
10

charm

The Charm Tool and Library ๐ŸŒŸ
Go
2,177
star
11

glamour

Stylesheet-based markdown rendering for your CLI apps ๐Ÿ’‡๐Ÿปโ€โ™€๏ธ
Go
2,057
star
12

pop

Send emails from your terminal ๐Ÿ“ฌ
Go
2,044
star
13

log

A minimal, colorful Go logging library ๐Ÿชต
Go
1,901
star
14

skate

A personal key value store ๐Ÿ›ผ
Go
1,167
star
15

wishlist

The SSH directory โœจ
Go
959
star
16

harmonica

A simple, physics-based animation library ๐ŸŽผ
Go
945
star
17

melt

๐ŸงŠ Backup and restore Ed25519 SSH keys with seed words.
Go
418
star
18

kancli

A tutorial for building a command line kanban board in Go
Go
155
star
19

vhs-action

Keep your GIFs up to date with VHS + GitHub actions ๐Ÿ“ฝ๏ธ
TypeScript
141
star
20

keygen

An SSH key pair generator ๐Ÿ—๏ธ
Go
101
star
21

bubbletea-app-template

A template repository to create Bubbletea apps.
Go
99
star
22

inspo

Share and explore projects you can build with Charm libraries
87
star
23

taskcli

A tutorial for building a Taskwarrior-inspired task tracker in Go using glamorous CLI libraries
Go
77
star
24

wizard-tutorial

A basic wizard made with Bubble Tea and Lip Gloss. Follow along with the tutorial video for this project:
Go
73
star
25

tree-sitter-vhs

Syntax highlighting for VHS with tree-sitter ๐ŸŒณ
C
69
star
26

x

Charm experimental packages.
Go
65
star
27

confettysh

confetti over ssh
Go
49
star
28

catwalk

Open source 3D models from Charm ๐Ÿงธ
49
star
29

soft-serve-action

Synchronize GitHub repositories to your Soft Serve instance ๐Ÿฆ
43
star
30

git-lfs-transfer

Server-side implementation of the Git LFS pure-SSH protocol
Go
42
star
31

promwish

Prometheus middleware for Wish
Go
37
star
32

meta

Charm's meta configuration files ๐Ÿซฅ
23
star
33

homebrew-tap

Our homebrew tap ๐Ÿบ
Ruby
21
star
34

scoop-bucket

Charmbracelet Scoop Bucket
14
star
35

nur

Nix
13
star
36

.github

1
star