Skip to content

Connect a Linux server

Give your agents a Linux server to work on, in place of SSH: install Sidekick for Linux, sign it in once, and choose what they may do there. The server connects out to your installation, so there is no port to open and no SSH key to keep. It runs from boot with nobody logged in, and reconnects by itself after a reboot or a restart of your installation.

Before you start

Sidekick for Linux gives an AI a shell and files on the server, and root too if you allow it. What it changes there is changed, and nothing here undoes it. It suits people who already run servers and have some experience of working with AI.

You need:

  • A server running Debian 11, Ubuntu 20.04, RHEL 8 or one of its rebuilds (Rocky, Alma), or a later version of any of them; or a current Fedora; or Amazon Linux 2023. It must use systemd, on x86_64 or ARM (aarch64).
  • Root on the server, or an account that can use sudo.
  • Your installation's address, the one you type into the browser, and a browser on any device where you can sign in to it.
  • Arc 4.0.25 or later on your installation. Admin > Overview (/admin) shows the version.

Install it

Sidekick for Linux is a pre-release for now, so it installs from the testing channel. Run this on the server as your usual account:

curl -fsSL https://pkg.1p.dev/sidekick.sh | sh -s -- --testing

The script adds Sidekick's signed repository to apt or dnf and installs the sidekick package. It uses sudo for the steps that need root, which may ask for your password. It does not sign in: it ends by printing the command that does.

The service starts straight away, but it reaches nothing until you sign it in.

By hand. If you would rather not pipe a script to a shell, add the repository yourself.

On Debian and Ubuntu:

curl -fsSL https://pkg.1p.dev/sidekick.gpg | sudo tee /usr/share/keyrings/sidekick-archive-keyring.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/sidekick-archive-keyring.gpg] https://pkg.1p.dev/apt stable main" | sudo tee /etc/apt/sources.list.d/sidekick.list
sudo apt update && sudo apt install sidekick

On Fedora, RHEL and its rebuilds, and Amazon Linux:

sudo curl -fsSL -o /etc/yum.repos.d/sidekick.repo https://pkg.1p.dev/sidekick.repo
sudo dnf install sidekick

The packages and the repositories are signed by Generation One Malta Limited. The key's fingerprint is 9C1E A04E DE74 7C7A 6C61 52F7 3C85 EC50 C3C0 A6C7. With gpg installed, curl -fsSL https://pkg.1p.dev/sidekick.asc | gpg --show-keys prints it, to compare.

Channels. Only pre-releases have been published so far, and they are on the testing channel, which is why the command above has --testing. The stable channel has no release yet: until it has one, the plain command, curl -fsSL https://pkg.1p.dev/sidekick.sh | sh, tells you to run it again with --testing. Once a stable release is published, the plain command installs it. By hand, the apt and dnf lines below name the stable channel; put testing in place of stable in the apt line, or fetch sidekick-testing.repo in place of sidekick.repo for dnf.

Sign it in

  1. On the server, run sudo sidekick login followed by your installation's address, starting https://. It needs root, and says so if you leave out sudo.
  2. It tells you what the sidekick account can do with sudo (see Sudo), then asks Which access should agents have on this server. Choose 1 to 4, or press Enter for Off. Choose what it may do explains the four.
  3. It prints an address. Open it in a browser on any device, and sign in to your installation if the page asks.
  4. The page asks Connect another computer? and names the server. Approve only if you have just run sidekick login on that server yourself. If someone sent you the address, or you did not start this, choose Cancel.
  5. Choose Approve. The page shows Your sign-in code with a Copy button.
  6. Paste the code into the terminal at Code or address: and press Enter. The whole address the browser ended on works too.

The code works once, for five minutes, so never give it to anyone else. The server then appears on your installation's Devices page, Admin > Devices (/admin/devices), and your agents can reach it by its name.

sudo sidekick login takes three options:

  • --access off, observe, change or full gives the access without asking. With no terminal to ask on and no --access, access starts at Off.
  • --name sets what your installation calls the server. Without it, the server's host name is used.
  • --no-sudo takes away the sidekick account's sudo before signing in (see Sudo).

Each server signs in on its own, with its own sudo sidekick login. Servers cloned from one image do not knock each other off your installation.

Choose what it may do

A server has no screen, so the four choices are about the shell and files:

  • Off. Connected, but the agent can do nothing.
  • Observe only. Reading files in the folders you grant. Nothing is changed.
  • Change things. Running commands, and reading and writing files in the folders you grant.
  • Full access. The shell, and every file the sidekick account can open.

Change the access at any time with sudo sidekick access off, observe, change or full. sidekick access on its own shows where it is, and sidekick off is short for sidekick access off.

Only root can raise the access. Anyone with an account on the server can lower it, without sudo, which suits a colleague who sees something they do not like.

The ceiling and the folders

Root also sets a ceiling: the highest access this server gives, whatever an agent or anyone else asks for. It lives in /etc/sidekick/access.toml, which Sidekick writes the first time root raises the access, and it survives a reboot. sidekick ceiling shows it, and sudo sidekick ceiling observe (or any of the four) sets it.

The same file lists the folders the file tools may reach under Observe only and Change things. Edit it as root and add one [[folder]] block for each:

access = "change"

[[folder]]
path = "/srv/app"
access = "rw"
label = "app"

[[folder]]
path = "/var/log"
access = "r"

path must be a full path. access is "r" for read only or "rw" for read and write, and a folder with no access is read only. label is optional. Under Observe only every folder is read only, whatever the file says. Sidekick reads the file again every few seconds, so a change takes effect without a restart.

The file must stay root's: if another account owns it or its folder, or anyone else can write to either, Sidekick does not believe it and runs at Off, and sidekick status says why. A file it cannot make sense of, such as one with a mistyped line, is treated the same way.

The folder list limits the file tools only. Under Change things the agent also has a shell, which reaches whatever the sidekick account can, and with sudo on that is everything.

Sudo

The service runs as an account of its own, sidekick, not as root. The package installs /etc/sudoers.d/sidekick, which lets that account run every command with sudo and no password. There is no terminal for the agent to type a password into, so it writes sudo -n in front of a command that needs root.

  • It is not a sandbox. With sudo on, any access that gives a shell (Change things or Full access) is root on the server. The sign-in says so before you choose.
  • Every root command is in the server's own log, as for any use of sudo.
  • Turn it off with sudo sidekick login --no-sudo and your installation's address. It empties the file to one comment line, and upgrades keep it empty. Empty it rather than deleting it, which an upgrade would undo.
  • Narrow it by editing the file as root, with sudo visudo -f /etc/sudoers.d/sidekick, to name the commands the account may run. Upgrades keep your edits.

The agent is told where things stand, in a line such as [Sidekick on web-01: Full access, bash, as sidekick, sudo without a password]. With the file narrowed it says sudo without a password for some commands, and with it emptied, no sudo. Sidekick checks sudo again every 15 minutes, and tells the agent when the answer changes.

See where it stands

sidekick status shows everything, and anyone on the server can run it:

Sidekick 0.1.0 on web-01
  Instance    https://<your installation>, signed in as frank
  Connection  connected
  Access      Change things: run commands, and read and write files in the granted folders
  Ceiling     Change things (/etc/sidekick/access.toml)
  Folders     /srv/app (app, rw)
  Account     sidekick, sudo without a password
  Sessions    1 open; a control group per session
  Machine id  1a2b3c4d

When the access is lower than what was asked for, the Access line says why: paused, or held down by the ceiling. A Problem line names anything wrong, such as a ceiling file Sidekick does not believe. sidekick status --json gives the same for a script.

Pause and stop

  • sidekick pause stops the agent at once, and anyone on the server can run it. Only root can resume. Without sudo it is best effort against an agent that can run code as the sidekick account, and the tool says so.
  • sudo sidekick pause is the pause to rely on. It is written into /etc/sidekick/access.toml, so it survives a reboot and the agent cannot undo it. sudo sidekick resume takes it away.
  • Off, a pause, signing out and Forget on the Devices page all end everything the agent started on the server, including work left running with nohup or in tmux.
  • sudo systemctl stop sidekick stops the service, and it stays stopped until root runs sudo systemctl start sidekick. A reboot starts it again; sudo systemctl disable --now sidekick keeps it off across reboots, or use sudo sidekick pause.

Keep it up to date

Sidekick updates with the rest of the server, through sudo apt upgrade or sudo dnf upgrade. On Debian or Ubuntu with unattended upgrades, it is only included if you have allowed its repository there.

An agent can run the upgrade from inside its own Sidekick shell. The service does not restart in the middle: it waits until no command is running, then restarts by itself and reconnects. Until then sidekick status shows a Restart line.

Remove it

  1. Run sudo sidekick logout. It asks your installation to forget the server.
  2. Uninstall the package, from your own terminal rather than an agent's shell: removing it stops the service, which ends that shell and can cut the package manager off part way.
  3. On Debian and Ubuntu, sudo apt remove sidekick stops and uninstalls it, and leaves its sign-in, settings, account and sudoers file in place. sudo apt purge sidekick removes those too.
  4. On Fedora, RHEL and Amazon Linux, sudo dnf remove sidekick removes everything, including the sign-in, the settings in /etc/sidekick, the sidekick account and the sudoers file.

If you uninstalled without signing out first, open Admin > Devices (/admin/devices) and choose Forget on the server's row. Forget works the same way while the server is still installed: it disconnects it, and the server stops trying to reconnect until someone signs it in again. Revoke bans it for good, for a server that is lost or not yours.

What it does not do

  • It has no screen and no desktop control. A desktop app for a Linux computer may come later.
  • It has no interactive terminal. Agents work in commands, and a program that insists on a terminal runs under script or in tmux.
  • It has no port forwarding and no scp. Files move through Sidekick's file tools, within their size limits.
  • It comes only as these packages: there is no store version, and no Snap or Flatpak.
  • It is not a sandbox. Choose the access that matches the job.

When it does not work

  • sidekick status says the service is stopped: someone ran sudo systemctl stop sidekick. Run sudo systemctl start sidekick, and systemctl status sidekick says why it stopped.
  • The Connection line says the server was forgotten by the instance: it was removed from the Devices page. Sign it in again with sudo sidekick login and the address it names.
  • The access is Off and you did not choose that: look at the Access, Ceiling and Problem lines. A pause, a ceiling at Off, or a ceiling file that someone other than root can write all hold it there.
  • The agent says it was refused: its message names the command to run, such as sudo sidekick access change, or the [[folder]] entry to add.
  • The page in the browser shows no code to copy: your installation is older than Sidekick for Linux expects. Update it to Arc 4.0.25 or later, then run sudo sidekick login again.
  • The script says the system has neither apt nor dnf: the server is not one of the systems above. The script names a plain archive at https://pkg.1p.dev/tarball/, with its own instructions.

Sidekick describes the rest of Sidekick; When something goes wrong covers the rest of the installation.