Remote machines
Your agents can run on a bigger machine than the one you carry: a dev server, a cloud VM, the desktop at home. cornercase remote opens the window on your laptop and attaches it to the cornercase server on that machine:
cornercase remote devboxdevbox is anything ssh takes: a host from ~/.ssh/config, or user@host. cornercase runs your own ssh, so your config, keys, agent, ProxyJump and ControlMaster all apply, and cornercase never sees a password or a key.
your laptop devbox cornercase remote ── ssh ───────────▶ cornercase proxy ──▶ cornercase server ── shells, agentsOn the other machine, ssh runs cornercase proxy, which finds the server (or starts one if none is running), whatever environment the SSH session has, and passes the window’s keys and the server’s screens back and forth. It is the same server that cornercase on that machine attaches to, so you can also open it from a terminal there: the windows mirror each other, as described in Sessions and the server.
What you need
Section titled “What you need”cornercase on both machines, in the same version for the window, and for commands the same or a newer one on the other machine (see Versions). On the other machine, it is looked for on the PATH, then in ~/.local/bin (where the install script puts it), ~/.cargo/bin and Homebrew’s folders, since the PATH of a command run through ssh is often shorter than your login shell’s. If it lives somewhere else, say how to run it with --command:
cornercase remote devbox --command '~/tools/cornercase'The other machine’s sh reads it, so ~ and $HOME work.
A Windows machine at the other end
Section titled “A Windows machine at the other end”The other machine can run Windows, with cornercase installed there and Windows’ OpenSSH Server running (an optional feature of Windows; adding it needs an administrator). Its sshd runs commands with cmd or PowerShell rather than sh, so the first time you connect, cornercase finds out which one with a harmless echo, then runs the proxy in a line written for that shell, and remembers the answer for that host, so later connections and reconnects go straight to it. That first connection takes three ssh sessions instead of one (three password prompts, if you log in with a password). A Linux or macOS machine pays nothing when the connection works; only when it fails before reaching cornercase in a way that cmd or PowerShell could explain (an exit status of 1) does cornercase send that echo once before reporting the error, one more ssh session and, with a password login, one more prompt.
The answer is kept in remote-shells.json, in cornercase’s state folder on the machine you connect from (~/.local/state/cornercase/, or %LOCALAPPDATA%\cornercase\ on Windows). When the remembered shell stops working, for instance because the name now reaches another machine, cornercase asks again by itself; deleting the file, or that host’s entry in it, makes it forget.
The first time, cornercase --remote winbox kill-server, restart, update and the other plugin commands (a --preview too, since it fetches) fail there and tell you to run them again, since cornercase doesn’t repeat a command that may already have done something; logs, plugin list and plugin logs are run again through the right shell by themselves.
There, cornercase is looked for on the PATH, then in %USERPROFILE%\.local\bin, where the PowerShell installer puts it, and %USERPROFILE%\.cargo\bin. --command takes the path of cornercase.exe, the same for cmd and PowerShell, with ~\ for your profile folder:
cornercase remote me@winbox --command 'C:\tools\cornercase.exe'cornercase --remote me@winbox --remote-command '~\tools\cornercase.exe' statusA path holding %, ! or " is refused when the shell there is cmd, which would read them as its own.
What runs where
Section titled “What runs where”Everything that touches files or programs stays on the other machine: the shells, the agents, worktrees and git, the changes and files panels, open (your editor opens in a new tab there), Usage and stats, the issue trackers (gh and your tokens live there), and its config.json, session.json and stats.json. A stats share link still copies to your local clipboard through OSC 52.
Your laptop only shows the window. Keys, the mouse, pastes and your terminal’s colours come from it, and copying, desktop notifications and the images the files panel shows go through it, so the text lands in your local clipboard, the notification on your local screen and the picture in your local terminal. A sound plays on your laptop too, with a file path read there; a window opened with ssh -t host cornercase plays none.
A port a dev server listens on there can be tunnelled to your laptop, and its open then opens it in your browser here. open in… can’t open the other machine’s folders in your laptop’s Finder or editors, since they aren’t there: the project, workspace and pane menus offer copy path instead, which copies the path as the other machine knows it. See Open in another app.
Tunnel a port to your laptop
Section titled “Tunnel a port to your laptop”A dev server in a pane of devbox listens on that machine’s own localhost, which is not your laptop’s. Open the workspace’s ports dialog (right-click or ⋯ on its row, then ports, or More ▴ › ports; its every port lists all of devbox’s) in a window from cornercase remote, and a program that listens on every address, 127.0.0.1 or ::1 has a tunnel button. It runs your own ssh to forward that port to your laptop:
ssh -N -T -o BatchMode=yes -o ExitOnForwardFailure=yes -o ControlPath=none \ -L 127.0.0.1:5173:localhost:5173 -- devbox- Same port, or another. The tunnel listens on the same port of your laptop when it’s free, so
http://localhost:5173works as it does ondevbox. When something there already uses it, it takes another port and the toast says which:port 5173 is tunnelled to localhost:5174 (5173 is taken here). - The row shows it.
⇄ …while it opens and⇄ :5174once it’s up, and the row then offers open (your browser openshttp://localhost:5174; it shows when your laptop has a default app), copy (that address) and close tunnel. The toast has an open button too. - It only reaches that machine’s own
localhost. A program that listens on a LAN address only has no tunnel button, and the server ofdevboxcan ask for a port number, nothing more: it can’t make your laptop reach a host or run anything. It can, however, find out which of your laptop’s local ports are in use, since the window checks whether the same port is free. - It is a plain
sshof yours, with the destination the window used, so your keys, agent andProxyJumpapply.BatchMode=yesmeans it never asks for a password, andControlPath=nonemakes it a connection of its own even with a sharedControlMasterin your config, so closing the tunnel really closes the port and it ends with the window. - Its ssh ends with the window, and when you switch to another machine or to this one, but the tunnel is remembered (see below). When the connection drops and the window reconnects, the tunnels come back. One that never came up (a taken port, a refused key) says why in a toast,
could not tunnel port 5173: …, and is tried again when you click tunnel or the window reconnects. A window holds at most 32 tunnels. - Scripts and agents see and drive the same tunnels with
cornercase tunnels,cornercase tunnel open PORT,cornercase tunnel close PORTandcornercase tunnel forget PORT, from a pane ondevboxor with--remote devbox: see Tunnels.
Remembered per machine
Section titled “Remembered per machine”The window remembers the tunnels of each machine, on your laptop (tunnels.json, beside session.json), so they are there next time:
- They come back. A window that reaches
devboxagain brings up its tunnels that are not closed, on the same port of your laptop when it’s free. - close and forget are different. close (the ports dialog’s close tunnel, the menu,
tunnel close) stops the ssh but keeps the tunnel listed asclosed, so it stays out of the way and open brings it back. forget removes it for good. - The machine button shows them.
devbox ⇄2 ▴counts the tunnels that aren’t closed. Its menu lists each one at its end, after the machines (⇄ 5173 → localhost:5174 up), and a click opens open in browser, close, open and forget, each only where it applies. A long name is cut, never the count. - Windows share them. With two windows on your laptop reaching
devbox, one runs the ssh and the other shows the tunnel up on the same port and starts none. When the first window ends, the other takes the tunnel over within a second or two.
Hold one without a window
Section titled “Hold one without a window”A program that has no window of its own, such as another interface for cornercase, can hold a tunnel itself:
cornercase --remote devbox tunnel hold 5173It starts its own ssh, waits until the tunnel is up and prints one line, {"port":5173,"local":5174,"url":"http://localhost:5174"}, then holds the tunnel until it ends. Killing it or closing its output ends it with status 0 (on Windows it does not notice its output closing). cornercase tunnel close 5173 or tunnel forget 5173 on devbox ends it with status 0 after one more line, {"ended":"closed"} or {"ended":"forgotten"} (a server that was not restarted after an update says nothing, and it ends with 0 and no line). When the server on devbox stops or restarts it prints {"ended":"server-stopped"} or {"ended":"server-restarted"} and exits with 7, so the program knows to hold the tunnel again once the server is back. A failing ssh or a lost connection ends it with 1. Your own server’s cornercase status --json lists each machine’s tunnels under its machines entry, other programs’ and windows’ holds included, so a program sees them without a connection of its own there. It needs --remote, and it remembers nothing: see Tunnels.
When 5173 is taken on your laptop, the hold listens on another port. --local 5174 names the one to take then, such as the port it had before, so a page you had open keeps working when the program holds it again (any free port when that one is taken too, and the line says which):
cornercase --remote devbox tunnel hold 5173 --local 5174A program that holds its tunnels this way can also take the ones a script or an agent on devbox asks for: cornercase --remote devbox tunnel orders prints a line such as {"order":"open","port":3000} for each cornercase tunnel open 3000, and the program answers with tunnel hold 3000, or with tunnel failed 3000 REASON. See Tunnels.
Reach your laptop from the machine
Section titled “Reach your laptop from the machine”The other direction: a port of your laptop, reachable on devbox, so an agent there can use, say, a headless Chrome’s DevTools port that runs on your laptop. A program on your laptop holds it:
cornercase --remote devbox tunnel hold --reverse 9222It runs ssh -N -R 127.0.0.1:PORT:localhost:9222 devbox and prints one line once it is up, {"port":41234,"local":9222,"url":"http://127.0.0.1:41234","direction":"reverse"}: port is the port on devbox, which its ssh server picked, and local the port of your laptop. --there 9223 asks for that port on devbox instead and fails at once when it is taken there. cornercase tunnels on devbox lists it as 41234 ← localhost:9222 up (reverse hold 4), and cornercase tunnel close --reverse 41234 on devbox ends it, as killing the program does; a plain tunnel close 41234 never touches it. Nothing on devbox can open one: only the computer whose port it is.
It listens only on 127.0.0.1 of devbox, but every program and every user of devbox can reach that, so on a shared machine others can use your port for as long as the hold runs (a browser’s DevTools port gives whoever connects that browser and its logins). If devbox’s sshd_config has GatewayPorts yes, it listens on every address whatever cornercase asks. See Tunnels.
If your ~/.ssh/config has a LocalForward, RemoteForward or DynamicForward for that host, the window’s own connection already holds it and every tunnel fails with Could not request local forwarding: remove it, or tunnel with your own ssh -L.
When the connection drops
Section titled “When the connection drops”The window stays open and says so:
It tries again at once, then after 1, 2, 4 and 8 seconds, then every 15 seconds, and shows the last thing ssh said. Your shells and agents keep running on the other machine meanwhile, and once it is back the window shows them as they are now. A laptop that slept or changed Wi-Fi comes back on its own.
Esc or quit gives up: the window closes and everything keeps running there, so cornercase remote devbox attaches again later. The Quit in the sidebar works as always: it detaches, and nothing reconnects.
Switch machines from the window
Section titled “Switch machines from the window”Once your list holds a machine (Settings › Machines, or a window that reached one with cornercase remote, or a program that added one: below), the bottom of the sidebar names where the window is, on a row of its own under Worktrees and Recap: this computer ▴, or on devbox ▴ once it moved. Click it to move the window somewhere else without closing it:
- this computer attaches it to the server on your laptop, and starts one if none is running.
- Every machine of your list, shown or not. On this computer each one opens a submenu: show its work here ✓ hides the machine (its link ends, its server keeps running there), show its work here · shows a hidden one again, and open the window there attaches the window there, with its command if it has one. On another machine a click attaches the window there at once, and the one the window is on has a
✓. - only this computer hides every machine and show all shows them all, each dim when it would change nothing; see Hide a machine. They show only while the window is on this computer.
- add machine… opens the form of Settings › Machines, and manage machines… opens that page. Both show only while the window is on this computer: on another machine the menu lists your computer’s machines and nothing else to change them.
- The tunnels the window holds, one row each, with what you can do to them: see Remembered per machine. The button then shows their count,
on devbox ⇄2 ▴.
There is no forget…: a machine is removed in Settings › Machines, where its link ends too.
The shells and agents of the machine you leave keep running there, and when you come back the window shows them as they are now. Until the other machine answers, the window says where it’s going and stays where it was: back (or Esc) returns at once. If the switch fails, for instance because ssh refused the key or the other machine runs another version, the window says why and you stay where you were.
Before reaching a machine a program added and no window has reached yet, the window asks first: connect (or Enter) goes, back stays. The question comes from the window on your laptop, not from the server it shows, so a server on another machine can’t send your laptop’s ssh anywhere: it can only pick among your own list.
The list is your computer’s list of machines, machines in config.json: a machine is added once and offers two things, show its work here (the server links it) and the window there. A machine a window reaches joins it, not shown, with the --command it used. The first time, the machines.json older releases kept beside session.json is moved into it, not shown, and removed. The button shows as soon as the list holds a machine, so it stays out of the way if you have none. With the icon bar it’s an icon above Help, and on a small screen it shares the Worktrees band of the projects menu.
A program on your laptop, such as another interface that offers to move to another server, reads the same list with cornercase remote --known, one machine per line, or as JSON:
cornercase remote --known --json{"machines": [{"name": "devbox", "destination": "devbox", "command": null}, {"name": "10.0.0.5", "destination": "me@10.0.0.5", "command": "~/bin/cornercase"}, {"name": "gpu-box", "destination": "gpu-box", "command": null, "unreached": true}]}The machines come in the order of the file, each with its name and its --command (null without one), and an entry the menu leaves out, such as one broken by hand, is left out here too. It reads the list on this computer, so it needs no server and no ssh, and CORNERCASE_REMOTE changes nothing for it (--remote is refused). unreached is there, true, for a machine a program added that no window has reached yet. Read the list this way rather than the file itself, whose shape can change with any release.
A program can change the list too, with no server and no ssh:
cornercase remote --remember me@10.0.0.5 --command '~/bin/cornercase'cornercase remote --forget devbox--remember adds a machine to the list, not shown, or gives one already there its new --command (leaving it out clears it), and --forget takes it off, as the × of Settings does: its link ends and its server keeps running there. The window asks before it first connects to a machine a program added, and stops asking once it has connected. A destination must be one word that doesn’t start with -, or the command exits with status 2, and forgetting a machine that isn’t on the list changes nothing and exits with 1. ssh must already know the host key of a machine a program added, because switching never asks for one: accept it with a plain ssh <host> once, or run cornercase remote <host> with the same --command (without it, the saved command is cleared), or the switch fails and says why. If config.json exists but can’t be read, --remember and --forget refuse it with status 1 and change nothing. A window that is already open sees the change the next time it connects (switching or reconnecting) or when it is opened again; a window that reconnects never writes its command over the list.
Versions
Section titled “Versions”For the window, both machines must run the same version of cornercase. When they don’t, it says which one to update before opening the window:
`devbox` runs cornercase 0.11.9 and this computer 0.11.12. Run `cornercase update` thereWhen the other machine is the older one, it offers to run cornercase update there for you, through ssh, and attaches once that is done. When there is no terminal to ask in, or you decline, it exits with status 5. When yours is older, run cornercase update on it.
The commands for scripts and agents are more relaxed: the other machine may run the same version or a newer one, so a script on your laptop keeps working when only devbox updates. When the other machine is the older one they refuse, since its server could ignore what a newer command asks for, and say how to update it from here:
`devbox` runs cornercase 0.11.9 and this computer 0.11.12. Update it from here with `cornercase --remote devbox update`They exit with status 5, so a program can tell this from a machine it couldn’t reach (a --remote-command wrapper that exits with 5 during update, restart, kill-server or logs passes it through too), and with --json they also print both versions (there is null when that cornercase is too old to say) and the command to update it as one line of JSON (see Exit status).
When the binary on the other machine was updated but its old server still runs, cornercase asks before restarting it, as it does on your own machine, and then runs cornercase kill-server there. After an update from the window’s own update dialog, which updates the other machine, the window reconnects to the new server by itself, and tells you if your laptop now needs the same update.
Commands for scripts and agents
Section titled “Commands for scripts and agents”The commands for scripts and agents reach another machine’s server too, with --remote. A script, an agent on your laptop or another interface can drive the server on devbox without building the ssh line itself:
cornercase --remote devbox status --jsoncornercase --remote devbox events --notices --host --jsoncornercase --remote devbox send --pane 12 - < prompt.mdcornercase --remote devbox files list '~/src' --jsoncornercase --remote devbox paste-file --pane 12 shot.pngcornercase --remote devbox clone git@github.com:acme/shop.git '~/src'cornercase --remote devbox start-serverCORNERCASE_REMOTE=devbox does the same without the flag, and the flag wins. Set it for one program, never in a shell’s rc file: it also applies in your panes, and the commands it sends away would stop acting on this machine. --remote-command is --command for these commands.
- Arguments and standard input arrive as they are, whatever the login shell there is: they travel inside cornercase’s own messages, not through a shell.
- The other machine may be newer than this one, but not older: the window needs the same version on both, the commands accept a newer one there and refuse an older one with status 5, saying how to update it with
cornercase --remote devbox update. - It never asks for a password, a passphrase or an unknown host key, since a script cannot answer: use a key in your SSH agent, and connect once by hand to accept the host key.
- Only
start-serverstarts a server there. The other commands sayno cornercase server is running on devbox, as they do on your machine. - A stream ends there when the command ends here, even when it is killed, so
eventsorstatus --follownever leaves a command running ondevbox. - Ids are that server’s, and last one run of it.
cornercase --remote devbox close --workspace 7 --boot BOOTorrename --workspace 7 NAME --boot BOOT(every command that takes an id takes it:send,read,events, …), with thebootof thestatus --jsonyou read the id in, refuses with status 4 when the server there restarted since, instead of acting on, or reading, whatever has that id now. See Arrange. - What a message says to run reaches the same machine. When a command there fails and names what to run next, the command it names has your
--remote devbox, and--remote-commandas you gave it, also whenCORNERCASE_REMOTEchose the machine, so it runs as written here (a--remote-commandwith spaces is quoted forsh, so in Windowscmd, which wants double quotes, quote it yourself; a command a message names for the machine it is about, such ascornercase updatethere, and the commands that stay on this computer, such ascornercase remote, are left as they are):cornercase --remote devbox send --pane 12 --enter -- "go on"that the agent did not record ends with…; `cornercase --remote devbox read --pane 12` shows where it is. With--jsontheerrorof each entry says the same.update,restart,kill-serverand the plugin commands, which run there as that machine’s owncornercase, print what it prints with the same--remote, whatever version it runs (update --checksayscornercase --remote devbox update);logs,plugin logsand what--jsonprints on stdout are left as they are, and so is everything printed by a run at a terminal from a Windows computer (ssh.exeis not tried with its output taken, see Known limitations). A refusal that server relays from one of its machines with--machine vpsnames that machine too:…`cornercase --remote devbox start --machine vps claude`. - Paths are the other machine’s, and the ones you type must be absolute:
open,clone(its folder and a repository’s path),plugin link,plugin install(its folder),config projectandflow save --pathrefuse a relative one. On a Windows machine they are Windows paths, such asC:\Users\me\srcor\\host\share\src.open,clone,plugin linkandplugin installalso take~/…, in that machine’s home folder (clonewithout a folder clones there), andstatusshows~/…for paths there. A.code-workspacefile given toopenis read there too, so its folders are that machine’s.filespaths are relative to the workspace, or absolute or~/…. The exception ispaste-file’s file, which is read here. - Give an agent there a file from here:
cornercase --remote devbox paste-file --pane 12 shot.pngcopies the file todevbox, keeps it in cornercase’s state folder there and pastes its path into pane 12, so the agent in it can open it, with noscp. With--boot BOOT, nothing is pasted if the server there restarted since you read pane 12. See Paste a file from another machine. - Clone there with files from here:
cornercase --remote devbox clone git@github.com:acme/shop.git '~/src' --file .env --from ~/code/shopreads.envhere, from the repository--fromis in, and the clone there gets it, with noscp. See Clone a repository. - Another interface can show that machine’s files:
files list,files readandfiles searchgive the files panel’s tree, viewer and search, andfiles list ~/a folder picker’s listing, so a UI on your laptop needs nosshof its own to read that disk. See Browse and read a workspace’s files. update,restart,kill-server,logsand the plugin commands run on that machine, as its owncornercasethroughssh: they ask their questions when you are at a terminal (--yesskips them), print what they print there (the commands they name have your--remote, see above, except inlogsandplugin logs, whose output is printed as it is, in what--jsonprints on stdout, and in a run at a terminal from a Windows computer) and exit with the status they have there.update --jsonprints what it did there as one line, so a program can confirm the install before it restarts that machine’s server (see Updates from a program).logs --followfollows that machine’s log and ends when nothing reads it. Ending or killing the command here calls off a--when-idlerestart that waits there, asCtrl+Cdoes on your own machine (both machines need 0.12.226 or newer). The plugin commands (plugin link,unlink,install,update,remove,enable,disable,listandlogs) manage that machine’s plugins, as Plugins describes. Onlyplugin windowsrefuses--remote, with status 2, since window processes run on the machine that shows the window.
cornercase --remote devbox update --yescornercase --remote devbox restart --when-idle --yescornercase --remote devbox logs --followcornercase --remote devbox plugin enable my-plugincornercase --remote devbox tunnel open 5173cornercase --remote devboxalone opens the window, ascornercase remote devbox.input --followtypes through one connection: a program that draws the terminals keeps one running for everything it types, instead of a command, and ansshconnection, for each batch of keys.requests --followsends every command through one connection: a program that draws cornercase keeps one running and pays a round trip per action instead of ansshconnection, as Many commands through one process describes.- One
sshconnection per command (except those two). To share one, use your own config:
Host devbox ControlMaster auto ControlPath ~/.ssh/cm-%C ControlPersist 10mGood to know
Section titled “Good to know”- Latency: every key goes to the other machine and comes back as a screen update, the same as typing in plain
ssh. - One window, one server: the sidebar shows the projects of one machine, though your machines’ workspaces do show in yours. Open another window to work on another machine.
- A link to each of your machines: list them in Settings › Machines, and your cornercase server keeps a link to the server on each one, starting it when none runs and never stopping it. See Machines.
- Commands for scripts and agents act on the server of the machine they run on, unless you give them
--remote. - Inside a pane:
cornercase remoteworks inside one of cornercase’s own panes, unlikecornercase, since the other server is a different one.