Enable agent remoting
As of v1.0.5, the zrok agent and controller support secure, opt-in remote control for creating shares and
accesses through the central zrok API.
Enable agent remoting in the zrok controller
-
Create an identity for your zrok controller to use for interacting with remote agents:
zrok2 admin create identity agentremotingnoteThe identity can be named anything;
agentremotingis used here as an example. -
Add the identity to your controller configuration:
agent_controller:
z_id: WEfGMIx-e4
identity_path: /home/michael/.zrok2/identities/agentremoting.json -
Restart your controller. The agent remoting endpoints will become available once it's running.
Enroll an agent
Enrolling an agent in remoting requires an enabled environment.
-
Run
zrok2 agent enrollfrom an enabled environment:zrok2 agent enroll -
Restart the agent. The following message confirms remoting is active:
Agent remoting API
- See the zrok OpenAPI spec for complete details of
/agentendpoints. - The
apiEndpointhttp://localhost:18080in the examples below refers to a local development controller. The credentials shown are already invalid and are included for illustration only.
Create a remote share
Call the /agent/share endpoint to create a share on a remote agent:
curl -H "X-TOKEN: ojF2fna5GKlt" -XPOST -H "Content-Type: application/zrok.v1+json" \
-d '{"envZId": "qDWmgIxne4", "shareMode": "public", "backendMode": "web", "target": "/home/michael/Repos/nf/zrok"}' \
http://localhost:18080/api/v2/agent/share | jq
Query the status of the remote agent
Call the /agent/status endpoint to see active shares and accesses:
curl -H "X-TOKEN: ojF2fna5GKlt" -XPOST -H "Content-Type: application/zrok.v1+json" \
-d '{"envZId": "qDWmgIxne4"}' \
http://localhost:18080/api/v2/agent/status | jq
Remove the remote share
Call /agent/unshare to remove a share, then verify with /agent/status:
curl -H "X-TOKEN: ojF2fna5GKlt" -XPOST -H "Content-Type: application/zrok.v1+json" \
-d '{"envZId": "qDWmgIxne4", "token": "51bnatug7ua3"}' \
http://localhost:18080/api/v2/agent/unshare
curl -H "X-TOKEN: ojF2fna5GKlt" -XPOST -H "Content-Type: application/zrok.v1+json" \
-d '{"envZId": "qDWmgIxne4"}' \
http://localhost:18080/api/v2/agent/status | jq
Create and remove private access
The /agent/access and /agent/unaccess endpoints allow for creating and removing private access frontends
remotely.
Unenroll an agent
Run zrok2 agent unenroll to remove all remote control access from an agent in an environment:
zrok2 agent unenroll
Unenrolling an active agent will produce ignorable errors. Restart the agent to resume unenrolled operation.