Skip to content

Quick Start

Set up your first VPN connection and run a remote command in 5 minutes.

This guide walks you through setting up Nefia from scratch: generating keys, enrolling a target PC, and running your first remote command.

Step-by-step Setup

1

Initialize configuration and VPN keys

Run nefia setup --skip-host to create nefia.yaml and generate the operator WireGuard keypair without creating an invite yet:

bash
nefia setup --skip-host

nefia setup is the canonical command and nefia init is an alias. If you prefer to generate the invite during setup, run nefia setup interactively or pass --non-interactive --host-name ... --host-os ....

2

Log in to your account

Authenticate with your Nefia account:

bash
nefia login

This opens a browser window for OAuth authentication. Once complete, the CLI stores a refresh token in your system keyring.

3

Create an invite token

Generate a single-use enrollment token for your target PC:

bash
nefia vpn invite --name my-server --os macos --stun

The --stun flag discovers your public IP automatically via STUN. If you know your public IP, you can use --endpoint your-ip:51820 instead.

4

Install and enroll the agent on the target PC

Run the one-liner installer with the invite token on the target PC:

bash
curl -fsSL https://www.nefia.ai/install-agent.sh | sh -s -- --token '<INVITE_TOKEN>'

This single command will:

  1. Download and install the nefia-agent binary
  2. Validate the HMAC-SHA256 signed token
  3. Try direct connection to the operator (falls back to cloud relay if needed)
  4. Perform a WireGuard key exchange
  5. Establish the VPN tunnel
  6. Register the SSH host key automatically
  7. Register as a system service (launchd / systemd)
5

Verify the connection

Back on the operator PC, check that the VPN tunnel is active:

bash
nefia vpn status

You should see output like:

nefia vpn status

VPN Status: active Local Address: 10.99.0.1/24 Listen Port: 51820

Peers: my-server (10.99.0.2) Status: active Endpoint: 203.0.113.10:51820

6

Run your first remote command

Execute a command on the target PC:

bash
nefia exec --host my-server -- hostname

Try reading a file and listing a directory:

bash
nefia fs read --host my-server --path /etc/hostname
nefia fs list --host my-server --path /var/log

Target all hosts at once:

bash
nefia exec --target all -- uptime

What's Next?

Now that you have a working connection, explore these topics:

Error Codes

Complete catalog of Nefia error codes with resolution steps.

Remote Execution

Execute commands across multiple hosts with targeting and concurrency control.

File Operations

Read, write, and sync files across your remote machines.

VPN Setup Guide

Learn about NAT traversal, key rotation, and advanced VPN configuration.

CLI Reference

Full reference for all Nefia CLI commands and flags.