Skip to content
HomeGitHub

First run

Start the interface with:

Terminal window
nearhost

It starts the proxy and every enabled project, and creates the local certificate authority, “Nearhost Local CA”, if it does not exist yet. Its key is kept in Nearhost’s data folder, not in ~/.config. See The local CA.

With no projects, the screen shows the Nearhost mark and “Nothing to serve yet.”, with the two ways in:

n add a project on this machine or a server
s add a server you reach over SSH

Below them are the folder you started in, whether the certificate authority is trusted, the proxy’s ports, and, from Nearhost 0.8.0, a link to Nearhost’s page at https://localhost:6327, or on the port --web-port gives, unless that port was taken or --web-port 0 turned it off. See TLS and the proxy. Press n to serve a project from this machine, or from a server you have added. Press s first if the project is on a machine you reach over SSH. See Add a server and Add a project.

While your system does not trust the certificate authority, a box titled “Welcome to Nearhost” opens over the screen. It says what will ask for your password:

  • now: trusting the local certificate authority, so browsers accept HTTPS from Nearhost’s web server
  • later: adding names to /etc/hosts

Press enter to trust it now, or s to skip. Skipping lasts until you next start Nearhost, and the box comes back while the authority is still untrusted. Once it is trusted you see “The local CA is now trusted.” and the box does not appear again.

Trusting installs the authority’s root certificate into your system trust store: the System keychain on macOS, your distribution’s certificate store on Linux. It is what lets your browser open https://<alias> without a warning.

Firefox, and Chromium-based browsers on Linux, keep their own stores. Nearhost updates those too when certutil is installed. See Install for the one-line setup.

If you skip, the proxy still runs and Home shows local CA ● not trusted. Run nearhost trust. You can trust it from a terminal at any time, and nearhost untrust reverses it:

Terminal window
nearhost trust

Two things need root: trusting the certificate authority, and adding your projects’ names to /etc/hosts. For both, Nearhost asks in a box titled “Password needed”, which says why:

Nearhost needs your password to add myapp.test to /etc/hosts.

Type your password and press enter, or esc to cancel. The password goes straight to sudo and nowhere else: it is not shown, logged or saved.

  • A wrong password shows “Sorry, try again.” After three, the step stops and nothing is changed.
  • Cancelling leaves things as they were. The certificate authority stays untrusted, or the project stays stopped until you start it again.
  • sudo remembers it for a few minutes, as it does in a terminal, so a second step soon after does not ask again.
  • If sudo asks every time, because it is set up not to remember, Nearhost hands over to the terminal for the password, then comes back.

/etc/hosts is only changed when a project starts and its names are missing, so most starts ask for nothing. See The hosts file.

macOS can let sudo take your fingerprint instead of your password, but it is off until you turn it on. Copy the template that macOS ships:

Terminal window
sudo cp /etc/pam.d/sudo_local.template /etc/pam.d/sudo_local

Then edit /etc/pam.d/sudo_local as root and remove the # from this line:

auth sufficient pam_tid.so

Check it in an ordinary terminal. This should show the Touch ID dialog:

Terminal window
sudo -k; sudo -v

With it on, Nearhost may still ask for your password the first time, then use Touch ID when it next needs root. Typing the password always works. Touch ID only works at the Mac itself, not over SSH. Inside tmux or another terminal multiplexer it may also need pam_reattach.

Once a project exists, the screen has a sidebar on the left, with Home at the top and each server’s projects below, and the selected row’s details on the right. Home shows:

  • proxy: whether it is serving, and on which ports
  • page: a link to Nearhost’s page at https://localhost:6327, or the port --web-port gives, once the proxy is serving. It is left out when that port was taken. Needs Nearhost 0.8.0 or later.
  • local CA: whether it is trusted, and when it expires
  • hosts: whether /etc/hosts has every project’s name
  • config: the path of the config file
  • running: how many projects are running, on how many servers

When something needs you, a problems section lists it, with why it happened and how to fix it. Below that is the recent log. Press l for the full-screen log, / to filter the sidebar by name, and h to come back to Home. ? lists every key. See Keyboard shortcuts.

Next: Add a server or, for a project on this machine, Add a project.