Link this machine to the hosted console (kya login)

kya login links the CLI on this machine to your hosted Shield KYA workspace. It uses the device code flow (RFC 8628): the CLI shows a short code, you approve the code in the hosted console while you are signed in, and the CLI saves a full-workspace API key on this machine.

The OSS CLI does not need an account. Run kya login only when you want the hosted console.

Steps

kya login
  1. The CLI prints a verification address and a code, such as WDJB-MJHT. It opens the address in your browser when you are at a terminal (not when KYA_NO_BROWSER=1).
  2. Sign in to the hosted console. Open the address, or Approve a kya login in the sidebar. Type the code.
  3. The console shows who is asking: the network address, the client string and the time. Only approve if you started this login yourself. If you did not, choose Deny. Deny is the default button.
  4. To approve, choose Approve a full-workspace key on the confirm step. The key can do anything an API key of that workspace can do. Only an owner or an admin can approve. A read-only user or an operator cannot.
  5. The CLI saves the key and prints its display prefix, for example sk_live_1a2b3c4d....

The code expires after about 10 minutes. The approval is good for 5 minutes: the terminal must collect the key within that time. If it expires, run kya login again.

Each review or decision in the console counts as an attempt. After ten attempts in 15 minutes, the approver must wait. A terminal that starts logins too fast from one network address gets “too many requests” and waits a minute.

Where the key is stored

File Mode Content
~/.kya/hosted-credentials.json (or $KYA_HOME/.kya/) 0600 The console origin, the API key, its display prefix and the time it was saved

The CLI never prints the full key. Do not paste this file into a ticket or a chat.

Options

Option or variable Effect
--base-url <url> The hosted console to use. Default https://shield-agent.com.
KYA_BASE_URL Same as --base-url, read from the environment.
KYA_NO_BROWSER=1 Do not open a browser. The CLI still prints the address and the code.

A console URL must use https. The only exception is a loopback address (127.0.0.1, ::1 or localhost) for local development. A URL with a user name, password, query or fragment is refused.

Sign out on this machine

kya logout

kya logout deletes the saved file on this machine. It does not revoke the key on the server. The key stays active until you revoke it in the hosted console: Settings, API keys.

What happens when something fails

kya login is an explicit command. On any failure it exits with code 1, prints one line and saves nothing:

Case Message (short form)
The user denies the request in the console the request was denied
The code expires the code expired before it was approved
The console does not answer, or answers in an unknown way the console sent an unexpected answer or lost the connection
The console does not offer hosted login hosted login is not available on this server
The address is not allowed (not https, not loopback) the console URL is refused
The workspace has the maximum number of API keys revoke an unused key in the console, then run kya login again

Hosted login never changes a verdict, an exit code of kya certify, or the OSS hook. Those commands do not read the saved key.

Calls to action (one line)

Some commands print one line that asks you to run kya receipt --share for a link to send a colleague:

Command When the line appears
kya certify The report has gaps.
kya receipt When the trail is too large to read in full, the line says the report shows only the newest part. Otherwise the line only asks for the share.
kya start The trail has 10 or more events.

A line appears at most once every 24 hours on this machine. It never appears when:

The line makes no network call and sends no telemetry.

Claim a shared report

You do not need kya login to keep a shared report. The live report (kya start) has a Share this report button in its header. It makes the same redacted public link as kya receipt --share and shows it with a copy control. If there is no network, the button shows an error and the report keeps working.

  1. Click Share this report. Send the public link to a colleague, and open it yourself to claim it.
  2. Type your email address on the shared page. We send one email with a link. Open it and press the button.

When you press the button, the account is created, the report is kept, and you get one summary email each week with the calls that ran, the calls that were blocked and the top reasons. Every email has a link that stops it without a login (it works for 90 days). Nothing is saved until you confirm the email address.

Claiming does not connect your computer. A link can be copied, so it must never hand out a key. To connect this computer, run kya login (the page after the claim shows the command): the CLI shows a code, you approve it in the console with your normal sign-in and second factor, and the CLI saves a key as described above.

Known limits