Skip to main content
The remote console is an IEx session on a device, carried over the connection the device already holds to NervesHub. You do not need SSH keys or a route to the device. Use it to inspect a running device, try a fix, or send it a file.
A console gives full access to the device’s Elixir runtime. Anyone who can open one can read secrets from the application environment and call any function on the device. Check who holds the device:console permission in production organizations.

Requirements

  • A device running nerves_hub_link with remote_iex: true. It is off by default.
  • The device is online.
  • The device:console permission. The built-in Manage and Admin roles hold it. The View role does not. A custom role can be given it. See Roles.
The console needs nothing extra on the NervesHub instance.

Enable it in firmware

Build and deploy firmware with this setting. Devices running firmware without it do not offer a console. The IEx process starts on the first data from NervesHub and stops after 5 minutes of inactivity. Change that with remote_iex_timeout, in seconds:

Open a console in the browser

1

Open the device

In your product, select Devices, then the device.
2

Select the Console tab

The tab is dimmed while the device is offline. When the device is online and its firmware has remote_iex: true, the terminal connects.
If the terminal shows “The device console isn’t currently available”, the device is offline or its firmware does not enable remote_iex. If it shows “You don’t have the required permissions to access a Device console”, your role lacks device:console. The session is shared. Everyone who has the Console tab open for the device sees the same console.

Send a file to the device

Drop a file on the console to send it to the device. NervesHub shows the upload, then the device receiving and saving the file. This needs nerves_hub_link 2.1.0 or later.

Open a console from the CLI

nh needs an interactive terminal. The session stays open until the device’s console ends or you press Ctrl-C.

Send code without a session

run-code sends Elixir code to the device’s console:
The output appears in the device’s console, not in the command’s output. To run code and get its output back, use a support script.

System shell

A shell on the device, as opposed to IEx, is a separate, optional extension with its own permission. It is mostly for devices that are not Nerves devices. See Local shell.

Console over iroh

nh can also open an IEx console over a peer-to-peer iroh connection, instead of through NervesHub’s WebSocket.

Requirements

  • The device runs iroh_console.
  • The device reports its iroh endpoint to NervesHub through the network identity extension, which needs nerves_hub_link 2.13.0 or later. nh reads where to reach the device from that report. See Network identity.
  • Your role can register network identities (network_identity:create). The built-in Manage and Admin roles can.

Connect

nh keeps one iroh key per organization in its data directory. The first time you connect, it registers that key with the organization, attached to you, under an instance named for your machine (nh-<host>-<key prefix>). The device authenticates you however its IrohConsole.Auth adapter is configured. nh prompts when the device challenges, or you can answer up front:
Press Ctrl-] to detach.
string
The response to the device’s auth challenge, such as a password or a TOTP code.
string
default:"iroh_console"
Which of the device’s iroh endpoints to connect to, for a device that runs more than one.

Manage iroh endpoints

Devices record their own endpoint ids when they connect. nh device iroh-console registers your machine’s. You only need to manage endpoints by hand for anything else.
The argument is the iroh endpoint id, not a device identifier. An id that is already registered anywhere is refused. The web UI has the same registry on the organization’s Iroh endpoints settings page. That page is hidden unless the NervesHub instance sets ORG_IROH_ENDPOINTS_UI_ENABLED=true. See Feature prerequisites.