cmux-ssh-here 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +48 -19
  2. package/bin.js +11 -1
  3. package/package.json +4 -1
package/README.md CHANGED
@@ -1,46 +1,75 @@
1
1
  # cmux-ssh-here
2
2
 
3
- One command spins up an ephemeral, token-authenticated SSH server on this machine and prints a [cmux SSH deep link](https://cmux.com/en/docs/ssh). Open the link in [cmux](https://cmux.com) and you instantly land in a shell as the current user over the local network — no `sshd` setup, no keys, no passwords.
3
+ **Share a shell on this machine in one command — no SSH setup, no keys, no passwords.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/cmux-ssh-here.svg)](https://www.npmjs.com/package/cmux-ssh-here)
6
+ [![CI](https://github.com/viktor-silakov/cmux-ssh-here/actions/workflows/ci.yml/badge.svg)](https://github.com/viktor-silakov/cmux-ssh-here/actions/workflows/ci.yml)
7
+ [![license](https://img.shields.io/npm/l/cmux-ssh-here.svg)](./LICENSE)
8
+
9
+ `cmux-ssh-here` spins up a throwaway, token-authenticated SSH server and prints a [cmux](https://cmux.com) deep link. Send the link to any device on your LAN, open it in cmux, and you're instantly in a terminal on this machine. When you're done, hit `Ctrl-C` — the server, token, and host key vanish.
4
10
 
5
11
  ```bash
6
12
  npx cmux-ssh-here
7
13
  ```
8
14
 
9
- Output:
15
+ That's it. No `sshd` to configure, no `~/.ssh/authorized_keys` to edit, no firewall dance.
10
16
 
11
- ```
12
- Connect to this machine via cmux over the LAN
13
- (shell as you; Ctrl-C here to stop):
17
+ ---
14
18
 
15
- https://cmux.com/deeplink/ssh?host=192.168.1.42&port=52968&user=wudUKicRFRw3&host-key-policy=accept-new&title=your-mac
16
- ```
19
+ The terminal turns into a live dashboard — the link, a countdown bar for its lifetime, and who's connected:
20
+
21
+ ![cmux-ssh-here dashboard](https://raw.githubusercontent.com/viktor-silakov/cmux-ssh-here/main/assets/dashboard.png)
22
+
23
+ Open the link and cmux connects on its own — one click, straight into the shell:
24
+
25
+ ![Open in cmux](https://raw.githubusercontent.com/viktor-silakov/cmux-ssh-here/main/assets/open-in-cmux.png)
26
+
27
+ ## Why you'll like it
17
28
 
18
- Open the linkcmux connects on its own. The server terminal shows a live dashboard: the current link, a countdown until it regenerates, and the list of connected sessions. `Ctrl-C` stops the server.
29
+ - **Zero setup** one `npx` command, no SSH server administration.
30
+ - 🔑 **No credentials to share** — auth is a one-time token baked into the link.
31
+ - ⏳ **Self-expiring** — the link rotates every 3 minutes; leaked links go stale on their own. Live sessions stay connected.
32
+ - 👀 **Live dashboard** — see the current link, a countdown bar, and every connected client at a glance.
33
+ - 🧩 **Real SSH** — full PTY shell, `scp`/`sftp`, and the exec channel cmux needs to bootstrap remote workspaces.
34
+ - 🪟 **Persistent sessions** — when `tmux` is present, sessions survive disconnects and are shared across connections.
19
35
 
20
- The link (and its token) is valid for **3 minutes**, then a fresh one is generated — already-connected sessions stay alive; only new connections need the new link.
36
+ ## Quick start
37
+
38
+ ```bash
39
+ # on the machine you want to reach
40
+ npx cmux-ssh-here
41
+ ```
42
+
43
+ Then open the printed `https://cmux.com/deeplink/ssh?…` link in cmux on any device on the same network.
21
44
 
22
45
  ## How it works
23
46
 
24
47
  - Its own SSH server (`ssh2`) with an ephemeral host key and token — both live only while the process runs.
25
- - The token is passed in the deep link's `user=`; the server only accepts the correct token.
48
+ - The token rides in the deep link's `user=`; the server accepts only that token, and rotates it every 3 minutes.
26
49
  - cmux deep links deliberately carry no passwords or keys, so the secret is the token itself.
27
- - Full PTY shell via `node-pty`, with window-resize support.
28
- - Real exec channel (raw pipes) and a filesystem-backed SFTP server, so `scp`/`sftp` work this is what lets `cmux ssh` upload and run its remote helper. A shell-only server is not enough for cmux.
29
- - When `tmux` is available, the interactive shell runs inside it: sessions persist and are shared across connections, and the session list (`choose-tree`) is shown on connect. Without `tmux`, it falls back to a plain login shell.
50
+ - Full PTY shell via `node-pty`, a raw-pipe exec channel, and a filesystem-backed SFTP server — together they let `cmux ssh` upload and run its remote helper (a shell-only server isn't enough).
51
+ - With `tmux` available, the interactive shell runs inside it: sessions persist, are shared across connections, and the session list (`choose-tree`) is shown on connect.
52
+
53
+ ## Compatibility
30
54
 
31
- ## Requirements
55
+ | Host running `npx cmux-ssh-here` | Supported |
56
+ | --- | --- |
57
+ | macOS | ✅ |
58
+ | Linux | ✅ |
59
+ | Windows | ❌ — needs a POSIX shell, and cmux's remote daemon has no Windows build |
32
60
 
33
- - Node 18+.
34
- - [cmux](https://cmux.com) on the device you open the link from.
35
- - macOS or Linux on the host sharing the shell. Windows host is not supported.
36
- - `tmux` (optional) for persistent, shared server-side sessions.
61
+ The device you open the link from just needs [cmux](https://cmux.com) installed. Node 18+ is required on the host. `tmux` is optional (for persistent, shared sessions).
37
62
 
38
63
  ## Security
39
64
 
40
- ⚠️ **The token in the link is a bearer secret that grants a shell as your user.** Trusted local network only. Don't publish the link or send it over untrusted channels. Close the terminal and the token and host key are gone.
65
+ ⚠️ **The token in the link is a bearer secret that grants a shell as your user.** Use it on a trusted local network only. Don't publish the link or send it over untrusted channels. Close the terminal and the token and host key are gone.
41
66
 
42
67
  ## Options
43
68
 
44
69
  - `PORT=2222 npx cmux-ssh-here` — fixed port (random free port by default).
45
70
  - `CMUX_SSH_TTL=600 npx cmux-ssh-here` — link/token lifetime in seconds before regeneration (default 180).
46
71
  - `CMUX_SSH_DEBUG=1 npx cmux-ssh-here` — log incoming auth/env/exec/shell requests to stderr (disables the live dashboard).
72
+
73
+ ## License
74
+
75
+ MIT
package/bin.js CHANGED
@@ -19,6 +19,14 @@ import { chmodSync } from "node:fs";
19
19
  import { createRequire } from "node:module";
20
20
  import { dirname, join, resolve } from "node:path";
21
21
 
22
+ // ponytail: the host side needs a POSIX shell + scp/exec semantics, and cmux's
23
+ // own remote daemon only ships linux/darwin/freebsd builds — so a Windows host
24
+ // can't serve `cmux ssh`. Fail fast with a clear message instead of crashing later.
25
+ if (process.platform === "win32") {
26
+ console.error("cmux-ssh-here must run on a macOS or Linux host (POSIX shell required). Windows is not supported.");
27
+ process.exit(1);
28
+ }
29
+
22
30
  // ponytail: node-pty's prebuilt spawn-helper sometimes unpacks without +x
23
31
  // (packaging bug) -> "posix_spawnp failed". Fix it before importing.
24
32
  if (process.platform !== "win32") {
@@ -50,7 +58,9 @@ const { privateKey } = generateKeyPairSync("rsa", {
50
58
  publicKeyEncoding: { type: "spki", format: "pem" },
51
59
  });
52
60
 
53
- const shellPath = process.env.SHELL || "/bin/zsh";
61
+ // ponytail: $SHELL is set on real logins; the fallback only matters in bare
62
+ // envs — bash on Linux, zsh on macOS.
63
+ const shellPath = process.env.SHELL || (process.platform === "darwin" ? "/bin/zsh" : "/bin/bash");
54
64
  const debug = process.env.CMUX_SSH_DEBUG ? (...a) => console.error("[debug]", ...a) : () => {};
55
65
 
56
66
  const lanIP = () =>
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "cmux-ssh-here",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Spin up a token-auth SSH server and print a cmux deep link to connect over LAN",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "cmux-ssh-here": "bin.js"
8
8
  },
9
+ "scripts": {
10
+ "test": "node --test"
11
+ },
9
12
  "files": [
10
13
  "bin.js",
11
14
  "README.md"