Skip to content
HomeGitHub

Install

Nearhost is one static binary for macOS, Linux and Windows 11, built for amd64 and arm64. Pick whichever of these fits how you install tools.

On macOS and Linux:

Terminal window
curl -fsSL https://nearhost.dev/install.sh | sh

The script detects your OS and CPU, downloads the matching release from GitHub, verifies its checksum and installs to /usr/local/bin when that is writable, otherwise to ~/.local/bin. It tells you when that folder is not on your PATH.

Three environment variables change what it does:

Variable Effect
NEARHOST_VERSION Install this release instead of the latest, as v0.8.0.
NEARHOST_INSTALL_DIR Install into this folder.
NEARHOST_SKIP_SETCAP Set to 1 to skip the Linux port step below.

Check the install with:

Terminal window
nearhost --version

nearhost --version needs Nearhost 0.8.0 or later. nearhost version prints the same, and works on releases before 0.8.0 too.

On Windows, in PowerShell:

Terminal window
irm https://nearhost.dev/install.ps1 | iex

The script detects your CPU, downloads the matching release from GitHub, verifies its checksum and installs nearhost.exe to %LOCALAPPDATA%\Programs\nearhost. It adds that folder to your user PATH, so open a new terminal before you run nearhost: a terminal that is already open keeps its old PATH. It runs in Windows PowerShell 5.1 and PowerShell 7, and if anything fails it stops with the reason and leaves an existing install as it was.

These environment variables change what it does. Set them before the command; a variable stays set for the rest of that PowerShell window:

Terminal window
$env:NEARHOST_VERSION='v<version>'; irm https://nearhost.dev/install.ps1 | iex
Variable Effect
NEARHOST_VERSION Install this release instead of the latest, as v<version>.
NEARHOST_INSTALL_DIR Install into this folder.
NEARHOST_NO_PATH Set to 1 to leave your PATH alone.

Each release on GitHub has a zip for each Windows build, nearhost_<version>_windows_amd64.zip and nearhost_<version>_windows_arm64.zip. Each holds nearhost.exe, LICENSE and README.md. Extract nearhost.exe to a folder on your PATH, or add its folder to your PATH in Settings, then open a new terminal.

To check the zip against the release’s checksums.txt, print its SHA-256 hash and compare it with the zip’s line there. PowerShell prints it in capitals and the file in lower case, which is the same hash:

Terminal window
Get-FileHash nearhost_<version>_windows_amd64.zip

On macOS and Linux:

Terminal window
brew install nearhost/tap/nearhost

With Go:

Terminal window
go install github.com/nearhost/nearhost/cmd/nearhost@latest

Nearhost needs Go 1.27.4 or later, the version the release binaries are built with. Go 1.21 to 1.27.3 downloads it first, unless GOTOOLCHAIN forbids it (some distributions’ Go packages set it to local). Then install Go 1.27.4 or later yourself.

A copy built this way reports its release version, rather than dev, so nearhost update can tell whether it updated.

Terminal window
npx @nearhost/cli

or npm install -g @nearhost/cli to keep the nearhost command. This works the same in PowerShell on Windows. npm installs the binary for your machine as a platform package, such as @nearhost/cli-linux-x64 or @nearhost/cli-win32-x64, with no install script, so pnpm, bun and --ignore-scripts work too.

To try the next release before it ships, install a beta with npm install -g @nearhost/cli@next, or run nearhost update --next on a copy installed with npm, pnpm, bun, go install or an installer. Homebrew has no betas. A new beta is published each time a change lands for the next release. Right after a release, next points at that release until the next beta. On a beta, nearhost update moves to newer betas and then to the release, and stays on releases from there.

The shell and PowerShell installers check the archive against the release’s checksums.txt. They do not check the attestation. Releases also carry build provenance attestations, and you can check any file you downloaded with the GitHub CLI:

Terminal window
gh attestation verify <file> --repo nearhost/nearhost

Each archive comes with a software bill of materials, <archive>.sbom.json, listing the modules it was built from. The attestation covers the archives, their SBOMs and checksums.txt. From Nearhost 0.8.0.

The macOS binaries are signed with a Developer ID certificate and notarised by Apple, so Gatekeeper runs them however you download them. A copy downloaded in a browser may need an internet connection the first time it runs, while macOS checks the notarisation with Apple. From Nearhost 0.9.0.

The Windows binaries are code signed, with ECS Software Consulting Ltd. as the publisher, so Smart App Control runs them. From Nearhost 0.16.0. See Code signing below.

Terminal window
nearhost update

updates Nearhost the way you installed it, after asking. Afterwards it checks the version of the copy your next command runs. If that copy is unchanged, it fails with Error: The update ran, but <path> is still <old>. and exits 1. On Windows, for a copy from the PowerShell installer or a zip, nearhost update downloads the release’s zip itself, checks it against the release’s checksums.txt and only then replaces nearhost.exe where it is, so a failed or cancelled download leaves your copy as it was. See nearhost update.

If Nearhost is running in the background, nearhost update restarts it on the new version, and asks first when that would close open passthroughs or forwards. See Updating.

nearhost update --check only reports, for scripts: it exits 0 when Nearhost is up to date, 1 when a newer release is out, and 2 when it could not check.

Linux needs three things that macOS handles with a single prompt. nearhost doctor checks all of them.

Nearhost serves HTTPS on 443 and redirects 80. A normal user cannot bind those ports, so grant the binary that one capability:

Terminal window
sudo setcap cap_net_bind_service=+ep "$(command -v nearhost)"

Run it again after each upgrade, because replacing the binary clears the capability. After any update, nearhost update prints the command, naming the real binary file, even for Homebrew, npm, pnpm and bun installs. It prints nothing when the binary still has the capability, or when the system lets any user bind port 80. The shell installer prints it as it installs, also when nearhost update runs it. Run from a downloaded copy at a terminal, rather than through curl | sh, the installer asks whether to run it, and only uses sudo if you say yes.

nearhost up stops with the same command when it cannot bind port 80 or 443 for want of the capability, and says Do not run nearhost with sudo. So does nearhost service install, which refuses a copy without the capability. See nearhost up. Running Nearhost with sudo leaves files owned by root in your config and data folders.

Installed from npm, command -v nearhost finds the Node launcher rather than the binary, so run the command nearhost doctor prints instead: it names the binary itself.

Terminal window
nearhost trust

This adds the Nearhost Local CA to the system trust store and asks for your password through sudo, which must be in /usr/bin, /bin, /usr/local/bin or /run/wrappers/bin and owned by root, from Nearhost 0.8.0. It uses your distribution’s own tool:

Distribution Command it runs
Debian, Ubuntu update-ca-certificates
Fedora, RHEL update-ca-trust extract
openSUSE update-ca-certificates
Arch trust extract-compat

Firefox and Chromium-based browsers on Linux keep their own certificate databases and ignore the system store. Nearhost fills them in when certutil is installed:

Terminal window
sudo apt install libnss3-tools # Debian, Ubuntu
sudo dnf install nss-tools # Fedora, RHEL

Then run nearhost trust again. It prints whether the browser stores were updated. Restart the browser afterwards.

The CA’s key is not in your config folder. See The local CA for where it is and how to look after it.

nearhost trust adds the CA to the System keychain, which Safari and Chrome use. Firefox keeps its own store. To cover it, install certutil and run trust again:

Terminal window
brew install nss
nearhost trust

Nearhost needs Windows 11, and Windows Terminal is the terminal it supports. nearhost doctor checks the parts below that it can.

From Nearhost 0.16.0, nearhost.exe is code signed through Microsoft’s Artifact Signing, with ECS Software Consulting Ltd. as the publisher. That holds however you install it: the PowerShell installer, the zip or npm. Smart App Control runs it. If you downloaded the zip in a browser, SmartScreen may still ask you to confirm the first run while the certificate builds a reputation. It names the publisher when it does: choose More info, check the publisher, then Run anyway. The PowerShell installer and npm don’t trigger it.

To check a copy, run this in PowerShell, with the path to your nearhost.exe:

Terminal window
Get-AuthenticodeSignature "$env:LOCALAPPDATA\Programs\nearhost\nearhost.exe"

Status should be Valid, and the signer certificate’s subject should name ECS Software Consulting Ltd. Installed from npm, the binary is in the @nearhost/cli-win32-x64 or @nearhost/cli-win32-arm64 package under your global node_modules.

Earlier releases are not signed. Where Smart App Control is on, Windows blocks them outright, with no Run anyway, so install 0.16.0 or later.

Nearhost uses the OpenSSH client that ships with Windows 11, ssh.exe, and your ~/.ssh/config, as on macOS and Linux. If ssh is missing, add OpenSSH Client in Settings > System > Optional features. nearhost doctor reports the version, and warns about one older than the 9.5 that Windows 11 ships.

Nearhost runs the first ssh on your PATH. Git for Windows puts its own ssh there, which reads another config and agent, so forwards can fail in ways that are hard to follow. nearhost doctor warns, under ssh vendor, when the ssh it finds is not in %SystemRoot%\System32\OpenSSH or %ProgramFiles%\OpenSSH, and gives its path. Put %SystemRoot%\System32\OpenSSH first on your PATH.

Windows’ ssh.exe cannot share one connection, so Nearhost logs in once for the server, once for each forward and once for each file it reads over SFTP. A key that needs a touch or an approval at each login asks once for each forward, and again for each forward every time the server reconnects. See SSH transport.

A key with a passphrase needs the ssh-agent service, which Windows installs disabled. In PowerShell run as administrator, start it and have it start with Windows:

Terminal window
Get-Service ssh-agent | Set-Service -StartupType Automatic; Start-Service ssh-agent

Then add your key, in an ordinary terminal:

Terminal window
ssh-add

A key without a passphrase needs no agent. nearhost doctor shows whether the service is running.

The OpenSSH in Windows 11, version 9.5, does not resolve a ProxyJump host given as an alias from your ~/.ssh/config. If a server is reached through a jump host, give ProxyJump the jump host’s address, or use a ProxyCommand. nearhost doctor says so when this is why a server fails.

nearhost trust adds the CA to your user’s certificate store, and Windows asks you to confirm it in a dialog of its own. It needs no administrator rights. Edge and Chrome use that store, and so does Firefox 120 and later, so no browser needs anything more. If Firefox has been set not to read Windows’ trusted roots, nearhost doctor warns and says which setting to change.

Each change to the hosts file, C:\Windows\System32\drivers\etc\hosts, needs administrator rights, so Windows shows a User Account Control prompt for it. See First run.

Windows lets Nearhost bind ports 80 and 443 with no extra step. The proxy listens on loopback addresses only, so Windows Firewall does not ask about it. If port 80 is held by HTTP.sys, often for IIS, nearhost doctor names it and says how to find and stop the service that holds it.

Nearhost runs on Windows itself, not inside WSL. To serve a project inside a WSL2 distribution, run sshd in the distribution and add it as a server, as you would any machine you reach over SSH. Nearhost installed inside WSL is the Linux build, and the Linux setup above applies to it.

Run nearhost. The first time, it offers to trust the certificate authority for you. See First run.