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
- 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 whenKYA_NO_BROWSER=1). - Sign in to the hosted console. Open the address, or Approve a kya login in the sidebar. Type the code.
- 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.
- 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.
- 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 output is JSON (
--json), orcertify --quietis used; - the
CIorGITHUB_ACTIONSvariable is set to a true value; - the output is not a terminal (for example a pipe or a file);
KYA_QUIETis set to a true value;KYA_CTA=0(oroff,false,no) is set;.kya/config.jsonin the project contains"ctaOptOut": true;~/.kya/cta.jsoncontains"optOut": true.
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.
- Click Share this report. Send the public link to a colleague, and open it yourself to claim it.
- 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.
- A report that nobody claims is deleted after 7 days. The shared page says so. A claimed report is kept.
- The page and the emails hold counts and public labels only. They never hold a command, a file path, a
project name or a session ID. The share payload is the same as before, and
kyasends nothing else with it. - If the address already has an account, the link asks you to sign in with that account first (with the second factor, if you use one). Nothing changes for a person who is not signed in. The account needs the owner or admin role.
- The first person who confirms a claim gets the report. A colleague who opens the public link can claim it too.
Known limits
- The key is a full-workspace key. There is no narrower scope yet. A scoped key type is a follow-up. The owner decides on it, and the feature flag stays off until then.
- If the console approves and the terminal does not get the key (the response is lost, or the terminal stops),
the key exists on the server but the terminal does not save it. The next poll is refused. Find the key in
API keys (its name starts with
kya login) and revoke it. - The approver check and the key creation run in one database transaction, but the approver row is not locked. A change to the approver made at the same moment can still pass the check. Rate limits are kept in memory per server process. With several servers, each one counts on its own.
kya logoutdoes not revoke the key on the server yet. Revoke it in the console.- A second
kya loginon the same machine saves a new key. The old key stays active until you revoke it. - The saved file is not the
--plane-configfile used bykya connect --hooks --hosted. That file also needs a registered agent id, whichkya logindoes not create.