wish README

项目的 README,来自 github.com/charmbracelet/wish。合并为一个 markdown 文件:README.md。

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:

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 kinds 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.

Contributing

See contributing.

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

wish (charmbracelet/wish)

正在搜索数据库…

5.6K ·GitHub
这是什么?Wish 是一个 Go 语言库,用于构建 SSH 服务器和应用。它提供合理的默认配置,并内置一组中间件,用于处理常见需求,例如通过 SSH 提供 Bubble Tea TUI 或 Git 仓库服务。
这是一个库,还是我需要单独运行的服务器?它是一个 Go 语言库,你需要将其导入自己的项目,用来构建定制的 SSH 服务器。它基于 gliderlabs/ssh 实现。
怎样把 Wish 添加到项目中?将它作为 Go 依赖使用,并结合内置中间件(bubbletea、git、logging、accesscontrol 等)搭建服务器。仓库的 examples 目录中也提供了独立示例,包括一个 Bubble Tea 应用和一个 Git 服务器。
服务器上需要安装 OpenSSH 吗?不需要。Wish 通过 gliderlabs/ssh 实现了自己的 SSH 服务器,因此从不使用 OpenSSH,也不需要它,甚至可以卸载。不过,git 中间件需要系统中已安装 git。
如果配置出错,客户端会不会意外获得 shell?不会。Wish 没有默认授予 shell 的行为,除非你明确自行构建,否则不存在意外暴露 shell 的风险。
Wish 自带哪些中间件?它包含 bubbletea 中间件,用于通过 SSH 提供 Bubble Tea TUI;git 中间件,用于通过 SSH 提供 Git 服务,并支持推送时自动创建仓库;logging 中间件;以及用于限制连接的 activeterm 和 accesscontrol 中间件。
我可以把 Wish 应用部署为系统服务吗?可以。README 中说明了如何通过 systemd 运行 Wish 应用:在 /etc/systemd/system/myapp.service 创建单元文件,最好使用专门的用户来运行。
有哪些实际应用是用 Wish 构建的?例如 Soft Serve、Wishlist、VHS、SSHWordle、pico.sh、SSH Slides 和 Charming 等,README 中还列出了其他应用。
为什么应用要用 SSH 而不是 HTTP?SSH 提供安全的通信,无需管理 HTTPS 证书;通过 SSH 密钥即可内置识别用户身份;并且可以从任何终端访问。同时,它还支持直接在连接上渲染 TUI。
有哪些类似的项目?shipyard, Surge, ttt, fiber, witr, bubbletea, slides, discobox
大小
1 MB
星标
5.6K
时长
6年
提交 · 90 天