Skip to content

External CLI

The shellrs command lets AI agents such as Codex, Claude Code and OpenCode run remote commands and transfer and sync files on the hosts saved in ShellRS, and also view, create, change and delete hosts and credentials. The command itself reads no passwords or private keys, and no database: it hands the request to the running ShellRS, which connects with the saved settings and the keychain. Requests travel over local interprocess communication: the socket cli.sock in the data folder on macOS and Linux (when the data folder’s path is too long for a socket, it goes in $XDG_RUNTIME_DIR instead, named by a hash of the data folder), and the named pipe \\.\pipe\shellrs-cli-<hash of the data folder> on Windows.

In Settings → External CLI:

  • Enable external CLI: off by default. While it’s off, ShellRS still listens but refuses every request, and the command tells you to turn it on here. Once it’s on, any program running as the current user on this computer can use the saved hosts this way, change hosts and credentials, and type commands into the remote terminals open in ShellRS (exec --terminal, including terminals that have switched to root); none of this has a separate switch. Only the current user can read and write the socket, and ShellRS also checks the identity of the user connecting. On Windows, the pipe likewise admits only the current user and only local connections, and before sending a request the command checks that the pipe belongs to the current user (or an administrator), so nobody else can grab a pipe with the same name.
  • Command: puts shellrs on the PATH.
    • macOS: links it to /usr/local/bin/shellrs; if that folder isn’t writable, the system asks for authorization.
    • Linux: links it to ~/.local/bin/shellrs. For the portable copy the link points to the shellrs in its folder, and the command talks to that copy; install it again after moving the folder.
    • On macOS and Linux, “Remove” deletes only a link that points to shellrs; other files with the same name are left alone.
    • Windows: a GUI app has no console, so the command is a separate console program, shellrs-cli.exe (next to shellrs.exe). “Install” copies it to %LOCALAPPDATA%\ShellRS\bin\shellrs.exe and adds that folder to the current user’s PATH (no administrator needed); terminals and agents find it once they’re reopened. After ShellRS updates, it refreshes this copy when it starts; when it can’t, “Update” appears. The copy can be updated even while it’s in use. “Remove” deletes the copy and takes the folder off the PATH. A portable copy copies it to bin\shellrs.exe in the portable folder and puts that bin on the PATH, so the command talks to that portable copy; install it again after moving the folder or when its drive letter changes. With both the installed and the portable command installed, whichever comes first on the PATH wins.
  • Agent Skills: writes the skill that teaches agents to use shellrs to the standard folder (~/.agents/skills) or to the skills folder of Codex, Claude Code, OpenCode or WorkBuddy; when the content differs from the current version, “Update” appears. “Copy skills” copies the whole skill to the clipboard.

Commands (shellrs --help has the full details):

shellrs hosts list [-q <keyword>] [--json]     # list hosts; JSON when the output isn't a terminal
shellrs hosts show <ID> [--json]               # one host's full settings
shellrs exec <ID> "<command>"                  # or --stdin to read the command from stdin
shellrs exec --json                            # read {"host", "command"} from stdin, print JSON
shellrs exec <ID> --terminal "<command>"       # run in a terminal already open in ShellRS; see below
shellrs upload <ID> <local-path> <remote-path>
shellrs download <ID> <remote-path> <local-path>
shellrs sync <ID> <local-folder> <remote-folder> [--delete]
shellrs hosts create | update <ID> | delete <ID>
shellrs credentials list | show <ID> | create | update <ID> | delete <ID>
  • <ID> is the 16-character host ID: the id in shellrs hosts list, which is also what “Copy ID” on a host’s context menu copies. The list also includes quick connections and external connections whose tabs are open ("temporary": true); see “Quick connect” and “Opening from a bastion host (external connections)”.
  • exec opens a new connection each time and disconnects when it’s done. The remote command gets no stdin, and the exit code is the remote command’s; if a signal killed it, the exit code is 128 plus the signal number.
  • exec --terminal ("terminal": true in exec --json) doesn’t log in again: it types the command into this host’s remote terminal that’s already open in ShellRS, for bastion hosts that allow only one login (see “Opening from a bastion host (external connections)”). It first sends Ctrl+C, which interrupts whatever program is running in the terminal and clears anything typed but not yet entered, then types a probe line and a command line; both lines and the command’s output show in the terminal. The command runs as the terminal’s current user, in its current folder and on its current machine (after su, sudo -i or a nested ssh too), and with --json the result has an extra context (user, host, cwd, shell, interp) saying where. The command’s output goes through a pipe, so programs don’t see a terminal: no colors or pager, and stderr comes as stdout. The command gets no stdin, and a program that asks for a password waits in the terminal. Which terminal it uses: the one the right sidebar is working on, if that’s this host’s; otherwise this host’s newest connected terminal.
    • Only bash, dash and busybox ash on Linux are supported (otherwise unsupported_shell). The encoded command line can be at most 4000 bytes for bash and dash, and 1000 bytes for busybox (otherwise too_long).
    • It fails with terminal_busy, and the command doesn’t run, when a full-screen program (vim, less, top, tmux and so on) has the terminal; the previous --terminal command hasn’t finished; the terminal is transferring files with ZMODEM; the shell doesn’t answer within 5 seconds (a foreground program that ignores Ctrl+C, such as python or mysql); or the shell doesn’t start the command within 15 seconds (the bastion host’s command filter or review may have held it back; Ctrl+C is then sent again). If the terminal isn’t open or isn’t connected, it fails with no_terminal.
    • There’s no time limit while the command runs; if the command-line tool is ended partway (say, by an agent’s timeout), the command in the terminal gets Ctrl+C.
    • The two lines start with a space, so bash with ignorespace set keeps them out of the history; otherwise they’re recorded. A shell waiting at a read -s without a prompt, or in the command mode of vi editing, can’t be recognized, and the command fails saying the shell didn’t answer.
  • Uploads and downloads use the SFTP tab’s transfer engine (recursive, .filepart, reconnecting after a drop), and destination paths follow scp’s rules: if the destination is an existing folder, the item goes into it under its own name; otherwise the destination is the path of the copy itself, and its parent folder must exist. Existing files are overwritten; new files keep the source’s executable permission. ~ means the login folder.
  • sync goes only from this computer to the host: it syncs the contents of the local folder into the remote folder. If the remote folder doesn’t exist, it’s created (its parent must exist); if it’s a file, that’s an error; and it can’t be the root folder /. Files whose size and modification time haven’t changed, and links whose target hasn’t changed, are skipped and counted as “unchanged” in the summary, so syncing again sends only what changed; other files are overwritten, and new files keep their executable permission. --delete first deletes items in the remote folder that aren’t in the local one, or are of a different type (without following links), but never the .filepart and .shellrs-….backup files that transfers in progress leave behind, and it doesn’t clean up folders that can’t be read locally; items it can’t delete count as failures.
  • hosts and credentials manage the saved hosts and credentials. create and update read a JSON object from stdin (update changes only the fields given); the fields are in shellrs hosts create --help and shellrs credentials create --help. What show --json prints can be edited and passed straight back to update. The checks are the same as in the dialogs, and errors use the dialogs’ wording:
    • Hosts: name, host (the address), port (default 22), user (default root), group (a group path such as Production/Databases, created level by level if it doesn’t exist; an error if more than one group has that path), auth (password / credential / no_password), credential (a credential ID), password, route (direct, jump hosts listed by ID, or an HTTP / SOCKS5 proxy; it can’t set a proxy command, which hosts show still shows and update without route keeps) and notes. Jump hosts must be saved SSH hosts, and not the host itself. If you change the address, port or user without giving a password, the saved password moves along, as in the dialog.
    • Serial hosts: protocol is serial (ssh by default), with serial in place of host, port, user, auth, credential, password and route. serial has device (required to create), baud, data_bits, parity (none / odd / even), stop_bits and flow_control (none / rts_cts / xon_xoff). Giving serial alone makes a serial host. exec (--terminal too), upload, download and sync fail on a serial host with not_ssh.
    • Telnet hosts: protocol is telnet, port is 23 by default, and user may be empty. auth is its automatic login: password types its own username and password, credential uses a password credential, and no_password doesn’t log in (the default; giving user or password without auth turns it on). telnet has the two prompts, user_prompt and password_prompt (null or empty for the usual ones), and telnet alone makes a Telnet host. A Telnet host can’t be a jump host, and exec, upload, download and sync fail on it with not_ssh too.
    • Credentials: name, kind (password / key / agent), user, password, key_path (a private key file on this computer) or private_key (the full text of a private key, like “Paste” in the dialog, kept in keys/ in the data folder), and passphrase. A credential’s ID is a 16-character random string, shown by credentials list.
    • Passwords, passphrases and private keys are write-only: they go into the system keychain or keys/, no command ever prints them, and show only says whether one is saved; for a private key ShellRS keeps, it doesn’t even show the path.
    • update can change protocol too: the host keeps its name, group and notes (between SSH and Telnet also its address, its connection, and its port unless that is a default), and the rest takes the new protocol’s defaults, which you can give in the same request (serial.device for a serial host). An SSH host that other hosts use as a jump host, or that port forwards go via, stays SSH.
    • Quick connections and external connections can be shown with show, but not changed or deleted.
    • hosts delete doesn’t ask for confirmation and deletes the host’s port forwarding rules along with it; the host’s open tabs in ShellRS stay open (--force is still accepted and does nothing). Hosts that jump through it are left with a “Deleted host” hop. credentials delete doesn’t ask either; hosts that use the credential switch to logging in on their own (as in the app).
    • ShellRS makes changes one at a time: a change that hasn’t had its turn within 10 seconds is withdrawn and not made; once it has started, the command waits for it to finish.
  • On failure, the command prints shellrs: [code] message to stderr and exits with 255. The error codes are not_running (ShellRS isn’t running), not_enabled (the external CLI isn’t enabled), host_not_found, credential_not_found, host_key_unknown (you haven’t connected to this host in ShellRS yet), host_key_changed, missing_credential (no saved password or passphrase), connect_failed, transfer_failed, bad_request, save_failed (the change was made but couldn’t all be written to the database or keychain), version_mismatch (the command and the running ShellRS are different versions, or ShellRS is too old to know the command), and no_terminal, terminal_busy, unsupported_shell and too_long, which only exec --terminal reports. The CLI never prompts: an unknown host or a missing password fails right away, so connect once in ShellRS first. When a transfer finishes but some items failed, the exit code is 1.
  • exec --json reads {"host": "<ID>", "command": "<command>"} from stdin and, once the command ends, prints {"exit_code", "stdout", "stderr"}, or {"error": {"code", "message"}} on an error, with the same exit codes as without --json. The output is ASCII only: Chinese and other characters are escaped as \uXXXX, and output that isn’t UTF-8 becomes U+FFFD. The command doesn’t go through the local shell’s quoting, and the console code page can’t garble the output, which suits Windows PowerShell and agents that need to read stdout and stderr separately.
  • macOS, Linux and Windows are supported. In Windows PowerShell, prefer exec --json for running commands (@{ host = '<ID>'; command = '…' } | ConvertTo-Json -Compress | shellrs exec --json). To watch the output while the command runs (long builds, lots of logs), pass the command as a here-string through --stdin instead (@'…'@ | shellrs exec <ID> --stdin), and, as for list, upload and download, first run $OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::new(), or Chinese and other non-ASCII text turns into question marks or garbage. Any BOM at the start of the command text is removed and CRLF becomes LF, so the remote shell sees no stray carriage returns.