@runloop/api-client - v1.18.1
    Preparing search index...

    Class DevboxNetOps

    Network operations for a devbox. Provides methods for managing SSH keys and network tunnels.

    Index

    Methods

    • Create an SSH key for remote access to the devbox. The public key is installed on the devbox and the private key is returned. The key can be used to SSH into the devbox. To use this you must add the private key to your SSH agent and configure it like this:

      The ssh user is the same user as defined in the DevboxCreateParams.launch_parameters.user_parameters user parameters of the devbox creation parameters.

      A special proxy command is required to allow SSH through the proxy. This is because the devbox is behind a proxy and the SSH client needs to be able to connect to the devbox through the proxy. The proxy command is:

      openssl s_client -quiet -servername %h -connect {sshUrl} 2>/dev/null
      

      This command uses the OpenSSL library to connect to the devbox through the proxy. The -quiet flag is used to suppress the output of the OpenSSL library. The -servername %h flag is used to specify the server name to connect to. The -connect {sshUrl} flag is used to specify the URL to connect to. The 2>/dev/null flag is used to suppress the output of the OpenSSL library.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<DevboxCreateSSHKeyResponse>

      SSH key creation result

      const sshKeyResponse = await devbox.net.createSSHKey();
      const sshUrl = sshKeyResponse.url;
      const sshKey = sshKeyResponse.ssh_private_key;

      NOTE: The ssh user is the same user defined in the DevboxCreateParams.launch_parameters launch parameters.

      ssh-config example:


      Host {devbox-id}
      Hostname {sshKeyResponse.url}
      User {user} # the user defined in the devbox params
      IdentityFile {keyfile_path} # the path to the `sshKeyResponse.sshKey` private key
      ProxyCommand openssl s_client -quiet -servername %h -connect ssh.runloop.pro:443 2>/dev/null # required to allow SSH through the proxy
    • Enable a V2 tunnel for the devbox. V2 tunnels provide encrypted URL-based access to the devbox without exposing internal IDs. The tunnel URL format is: https://{port}-{tunnel_key}.tunnel.runloop.ai

      Each devbox can have one tunnel. Tunnels can be configured with different authentication modes:

      • open: No authentication required (default), returns auth_mode: 'open'
      • authenticated: Requires a token for access, returns auth_token

      Parameters

      • Optionalparams: DevboxEnableTunnelParams

        Optional tunnel configuration

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<TunnelView>

      Tunnel details including tunnel_key and auth configuration

      // Enable a public tunnel
      const tunnel = await devbox.net.enableTunnel();
      console.log(`Tunnel URL: https://8080-${tunnel.tunnel_key}.tunnel.runloop.ai`);

      // Enable an authenticated tunnel
      const authTunnel = await devbox.net.enableTunnel({ auth_mode: 'authenticated' });
      console.log(`Auth token: ${authTunnel.auth_token}`);
    • Remove an existing V2 tunnel from the devbox.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<unknown>

      await devbox.net.removeTunnel();