{"slug": "a-unified-cli-for-native-os-keychains-x-keyring", "title": "A unified CLI for native OS keychains – x keyring", "summary": "X-cmd v0.10.2 introduces the `x keyring` module, a unified command-line interface that securely stores and retrieves credentials by calling native OS keychains—macOS Keychain, Linux Secret Service/KWallet, and Windows Credential Manager—rather than implementing its own encryption or file storage. The module aims to let shell scripts, automation tools, and AI agents manage API tokens and other secrets without expanding security boundaries or adding binary dependencies, addressing the challenge of where to store decryption keys.", "body_md": "# Stop Letting API Tokens Run Naked: Unifying Secure Storage Across macOS, Linux, and Windows\n\nTLDR\n\n- The\n`x keyring`\n\nmodule introduced in x-cmd v0.10.2 aims to solve the secure storage challenges of sensitive credentials like API tokens. Instead of implementing its own encryption or file storage, it acts as a connection layer that uniformly calls native secure storage capabilities of the operating systems, such as macOS Keychain, Linux Secret Service/KWallet, and Windows Credential Manager. This design avoids the security risks of applications managing decryption keys themselves. Without introducing additional binary dependencies, it allows shell scripts, automation tools, and AI Agents to securely store and retrieve credentials through a unified interface, returning the security boundary to the operating system and enabling tools to focus on their core tasks.\n\nx-cmd v0.10.2 has added the `keyring`\n\nmodule. This is just the beginning.\n\nFour years ago, we started looking into Vault and 1Password. The core question was actually quite simple: **How should a configuration file be designed to be both secure and convenient? Where exactly should things that cannot be stored in plain text be kept?**\n\nAPI tokens, SSH key passwords, and service credentials will eventually find their way into a developer's environment.\n\n## The Challenge Goes Beyond Encryption \n\nMany people's first instinct is to encrypt configuration files. But after encryption, there is an even more troublesome issue—**where do you put the decryption key?**\n\nStoring it with the encrypted file offers limited security; asking users to manage the key themselves degrades the user experience; and having the application manage it essentially expands its own security boundary.\n\nTherefore, the challenge has never been just \"how to encrypt,\" but rather **how to securely manage \"the ability to access the keys.\"** What Vault and 1Password solve is not just encrypted storage, but an entire key management workflow built around keys, access permissions, and usage processes.\n\n## The Operating Systems Already Have the Answer \n\nLater, we noticed that operating systems actually provide local key storage: macOS has Keychain, Windows has Credential Manager, and Linux has Secret Service and KWallet. They delegate the task of \"secure storage\" to the system.\n\nBut for shell script writers, these interfaces are fragmented and have different dependencies, making them difficult to call uniformly. Thus, the question became: **Can we turn the existing capabilities of the system into a unified interface within the shell?**\n\n## From Research to Implementation \n\nThis idea remained in the research phase until feedback appeared in GitHub discussion #455, prompting us to finally take action.\n\nThe positioning of `x keyring`\n\nis very clear: **It is not a new password library, but a connection layer** that allows shell users to call the system's own secret store in a unified way.\n\n## Why Not Implement Our Own? \n\nDuring implementation, we also considered a file backend, but ultimately abandoned it. Once we returned to file storage, we would immediately hit the initial problems: where to put the key, who protects it, and how to maintain consistency across platforms. Going further down that path would mean redesigning a password management system, which is not the direction x-cmd wants to take.\n\nSo we directly call the system's capabilities:\n\n- macOS → Keychain\n- Linux → Secret Service / KWallet\n- Windows → Credential Manager\n\nNo new binary dependencies are introduced, and no additional security boundaries are expanded.\n\n## Why Is This More Important Now? \n\nIn the past, key management was mostly a personal environment issue; storing a token on your own computer was fine. Now, automation tools are becoming increasingly prevalent—scripts, CI/CD pipelines, and the recent AI coding agents are beginning to execute tasks on behalf of users. Tools need permissions, but keys should no longer be scattered across configuration files, environment variables, or execution logs.\n\nAWS and 1Password have recently been discussing the risks when AI agents use secrets: credentials might end up in contexts, logs, or subsequent call chains, causing credential sprawl. Behind this is the same shift—as more tools execute tasks on behalf of humans, how to securely use keys will become a fundamental issue.\n\n## What Can `x keyring`\n\nDo Now? \n\n`x keyring`\n\ndoes not intend to recreate Vault or 1Password; it simply connects the existing secure storage capabilities of various platforms to the shell. The trade-off is having to accept the capability boundaries of different systems, but the benefits are:\n\n- No new binary dependencies\n- No additional supply chain risks\n- The security boundary remains the responsibility of the operating system\n\nScripts and tools no longer need to handle cross-platform storage differences themselves, nor do they need to redesign a solution just to store a credential. Besides storing tokens and managing SSH key passwords, it can also serve as a foundational capability for other tools—storing local notes, syncing SSH key passwords, or temporarily holding one-time credentials in automated tasks are all possible.\n\nThe goal is not to provide a closed password management experience, but to **make the existing security capabilities of the system more accessible to shells, scripts, and AI Agents.**\n\nFor developers, key management shouldn't be a problem that every tool has to solve from scratch. Letting the operating system handle secure storage while tools focus on completing tasks might just be simpler.\n\n`x keyring`\n\nhas been released with x-cmd v0.10.2, and we will continue to add more capabilities based on real-world usage scenarios in the future.\n\nPlease indicate the source and link of this article when reprinting.\n\nHelp us make these docs great!\n\nAll X-CMD docs are generated from command help and multiple data sources. See something that's wrong or unclear? Feel free to let us know through any of these ways~", "url": "https://wpnews.pro/news/a-unified-cli-for-native-os-keychains-x-keyring", "canonical_source": "https://www.x-cmd.com/blog/260811/", "published_at": "2026-08-13 03:26:08+00:00", "updated_at": "2026-08-13 03:40:49.601199+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents"], "entities": ["x-cmd", "macOS Keychain", "Linux Secret Service", "KWallet", "Windows Credential Manager", "Vault", "1Password"], "alternates": {"html": "https://wpnews.pro/news/a-unified-cli-for-native-os-keychains-x-keyring", "markdown": "https://wpnews.pro/news/a-unified-cli-for-native-os-keychains-x-keyring.md", "text": "https://wpnews.pro/news/a-unified-cli-for-native-os-keychains-x-keyring.txt", "jsonld": "https://wpnews.pro/news/a-unified-cli-for-native-os-keychains-x-keyring.jsonld"}}