Headless

Follow these four steps to install the NoPorts daemon in a headless environment

Step 1. Run the installer

  1. Change directories into the unpacked download:

cd sshnp
  1. Then run the installer:

./install.sh headless sshnpd

This will install the binaries to ~/.local/bin. Instead, if you'd like to install the binaries to /usr/local/bin, run the installer as root:

sudo ./install.sh headless sshnpd

Step 2. Configure the startup script

After installing the startup script, we must configure it.

vi ~/.local/bin/sshnpd.sh

You'll then be greeted with a file that looks like this:

https://github.com/atsign-foundation/noports/blob/trunk/packages/dart/sshnoports/bundles/shell/headless/sshnpd.sh
#!/bin/sh
# disable "var is referenced but not assigned" warning for template
# shellcheck disable=SC2154
# SCRIPT METADATA
binary_path="$HOME/.local/bin"
manager_atsign="@example_client" # MANDATORY: Manager/client address/Comma separated addresses (atSign/s)
device_atsign="@example_device"  # MANDATORY: Device address (atSign)
device_name="default"            # Device name
user="$(whoami)"                 # MANDATORY: Username
v="-v"                           # Comment to disable verbose logging
s="-s"                           # Comment to disable sending public keys
u="-u"                           # Comment to disable sending user information
delegate_policy=""
# END METADATA

sleep 10 # allow machine to bring up network
export USER="$user"
while true; do
	# The line below runs the sshnpd service, with the options set above.
	# You can edit this line to further customize the service to your needs.
	"$binary_path"/sshnpd -a "$device_atsign" -m "$manager_atsign" -d "$device_name" "$delegate_policy" "$s" "$u" "$v"
	sleep 10
done

Replace $user with the running sshnpd

Replace $device_atsign with the

Replace $manager_atsign with the

Replace $device_name with your own for this device. You will need this value later, so don't forget it.

$device_name must be alphanumeric snake case, max length 30 - e.g. dev_abc1

Add any additional config to the end of the line where sshnpd is run, some useful flags you should consider adding:

  • -u : "unhide" the device, sharing the username and making it discoverable by sshnp --list-devices

  • -s : "ssh-public-key", allow ssh public keys to be shared by sshnp and automatically authorized by sshd, saves you from dealing with ssh public key management. If multiple people use the device, we recommend leaving this off and managing ssh public keys yourself.

  • To see the rest of the available options run sshnpd to see the usage.

Step 3. Activate your device address

Step 3.1. First time activating your address

We will now activate the device address—you only need to activate the device address now. The client address will be activated later during the client installation.

Now that you have at_activate installed, you can invoke the command with the name of the address you would like to activate:

./at_activate -a @my_noports_device

Enter the One-Time Password (OTP) & Check your SPAM/PROMOTIONS folders

The application will pause and wait for the input of a one-time password (OTP) before you can continue. You should receive this pin to the contact information associated with the registration of your NoPorts address (i.e. email or text message).

***If you are using a gmail.com account we have seen that sometimes the OTP gets stuck in the SPAM or PROMOTIONS folder. If you do not see the OTP check those folders.

Once you receive the message, enter the pin into the application and press Enter to continue. The application should proceed to create the cryptographic keys and store them at .

An address can only be activated once, to install this address to future devices, you must copy this file to the device (see 3.b.).

Step 3.2. Activated this address before

The address will be located at . Copy this file from your other machine to the same location on the machine that you are installing sshnpd on.

Step 4. Start the service

The headless service will automatically be started by the cron @reboot directive when your machine restarts. If you would like to start it immediately, note that you must make sure to disown the process so that it doesn't hang up when you log out.

Run the following command to start it immediately:

nohup $HOME/.local/bin/sshnpd.sh > $HOME/.sshnpd/logs/sshnpd.log 2> $HOME/.sshnpd/logs/sshnpd.err &

Observing the service

The service should already be running in the background, to observe the logs:

tail -f $HOME/.sshnpd/logs/sshnpd.log
tail -f $HOME/.sshnpd/logs/sshnpd.err

Most of the logs will be found in sshnpd.err, it is usually worth checking that file first

Step 5. All done!

Your headless job is ready to go. You can now proceed to installing your client, or if you've already done that, check out our usage guide.

Last updated