Costs
Nebius Tunnels is provided free of charge during preview. If you create a VM for this guide, Nebius AI Cloud charges you for Compute resources.Prerequisites
-
Make sure you are in a group that has the
adminrole within your tenant or project; for example, the defaultadminsgroup. You can check this in the Administration → IAM section of the web console. You need this role to create a group and grant it a role for the tunnel. You also need theadminrole to create a VM with a service account attached. Create the service account in the same project as the VM. The tunnel agent authenticates as this service account, so it only needs the applicationtunnel.agent role for the tunnel. It doesn’t need any Compute permissions.A VM’s service account is set only at creation and can’t be changed afterwards. To attach a different service account, create a new VM. - Install and configure the Nebius AI Cloud CLI.
-
Check that your project ID is saved in the Nebius AI Cloud CLI profile configuration:
- Get the subnet ID for the VM you create.
-
Get the project ID and save it to an environment variable:
-
Get the tenant ID and save it to an environment variable:
You need the tenant ID when granting the service account access to Nebius Tunnels.
Steps
Create a tunnel
Create a tunnel and save its ID:Prepare agent access
On the VM, the tunnel agent authenticates through the instance metadata service — no need to generate or copy keys.-
Create a service account for the tunnel agent and save its ID:
-
Create a group for Nebius Tunnels service accounts and save its ID:
-
Grant the group the
applicationtunnel.agentrole for the tunnel: -
Add the service account to the group:
Create the VM
-
Prepare the cloud-init configuration file. You’ll attach it to the VM when you create it.
Save the following configuration to a file named
cloud-init.yamlin your working directory. Before saving, replace:<username>with the username you’ll use to connect<public_SSH_key>with your SSH public key<tunnel_ID>with the value of$TUNNEL_ID
cloud-init.yaml
This configuration enables the following actions:- Add a username and a public SSH key to the VM.
- Download the tunnel agent, verify its checksum and install it as a systemd service running under a dedicated
tunnasystem user. - Authenticate by using the service account attached to the VM, through the instance metadata service. No key files are involved.
- Create the
webNebius Tunnels service that exposes127.0.0.1:8080on the VM.
-
Create the VM:
In the command, specify the subnet ID from Prerequisites and the ID of the service account you created earlier.
-
Get the public IP address of the VM:
In the command, specify the name of the VM you created.
-
Connect to the VM:
Prepare and deploy a local HTTP service
Follow this section on your VM via SSH.
busybox HTTP server on your VM:
-
Install the
busyboxpackage: -
In your home directory, create a
www/directory and add an HTML file to serve via the tunnel: -
Create a unit file:
In the unit file, replace
<username>with the username you used to connect to the VM. -
Apply the new unit file, start the
busybox-httpdservice and check its status:
Verify the tunnel agent
Follow this section on your VM via SSH.
- The VM has no service account attached.
systemctl statusstill showsactive (running), but the agent retries indefinitely, showingIMDS token request failed: 404 Not Foundfollowed byconnection closed before registering. You can’t attach a service account to an existing VM. Create a new one with--service-account-idinstead. - The attached service account doesn’t have the
applicationtunnel.agentrole. The agent authenticates, but the tunnel rejects the connection. Grant the role to the service account as described earlier in this guide.
service_nameis theservices.namevalue from the agent configuration.tunnel_masked_IDis the mask of the tunnel ID without theapplicationtunnel-prefix and regional routing code. For example, forapplicationtunnel-e00abcdef123456789, the tunnel ID mask isabcdef123456789.regionis the region of the project where the tunnel was created, for exampleeu-north1.
Access the service on the VM via the tunnel
On your local machine, addhttps:// to the beginning of the public endpoint address and open it in your browser, or run curl https://<public_endpoint> in your terminal.