Let AI agents use SSH without seeing your keys
An AI coding agent that can run commands can run ssh. To do that it normally reads a private key from ~/.ssh, or you paste a password into the chat. Either way the secret ends up somewhere the agent, its logs or a prompt-injected web page can reach. LLLanyard keeps SSH logins in your keychain instead, and gives a connection the key for as long as it lasts.
Store a login
lllanyard ssh add prod --host deploy@prod.example.com # paste your existing private key (nothing is shown) lllanyard ssh add nas --host admin@192.168.1.5 --password # or a password lllanyard ssh generate web --host root@web1.example.com # or make a new key; prints the public half
The key goes into your operating system's keychain. If you made a new key, add the public half to the server's ~/.ssh/authorized_keys; lllanyard ssh pubkey web prints it again. Once you've checked a pasted key works, delete the original file.
Connect
lllanyard ssh prod # a session lllanyard ssh prod -- uptime # run one command lllanyard ssh with prod -- scp ./app.tar.gz deploy@prod.example.com:/srv/
When you connect, LLLanyard starts a private ssh-agent that only your user can reach, loads the key into it without writing a file, runs ssh, then stops the agent and deletes its folder. ssh with does the same for any program that uses SSH, such as scp, rsync or git. On Windows, which has no agent socket, the key is written to a private temporary file for the session and deleted afterwards.
Let an AI use it
An agent that runs lllanyard ssh prod -- uptime gets the output, never the key. lllanyard setup claude-code, setup codex and the others add instructions telling the agent to do exactly that. In Claude Desktop, the ssh_run tool runs one command only after you click Run in a dialog showing the login and the exact command.
Limit what a login can do
lllanyard ssh add prod --host deploy@prod.example.com --allow "uptime" --allow "df -h" --allow "systemctl status *" --expires 30d lllanyard ssh policy prod --confirm
--allowmeans only those commands run. The login can't open a shell or be used withscp, and any command with a shell operator (;&|$and so on) is refused.--confirmshows a dialog before every use, even from a terminal.--expires 30dstops the login working after that time.
These limit what an AI can ask for through LLLanyard. For a hard boundary, also give the login a restricted account on the server.
Things to know
- A changed host key is refused. LLLanyard keeps its own
known_hostsfile and leaves yours alone. - SSH logins are included in
lllanyard backup, and count towards your plan's key limit. - A command an agent runs in a terminal isn't behind the Run dialog unless the login has
--confirm, so keep the agent's own approval setting on for tools you don't fully trust.
Try it: LLLanyard is free for up to 10 keys.
npm install -g @lllanyard/cli lllanyard doctor
More guides
- Keep API keys out of Claude Code
- .env files and AI coding agents
- Keep MCP server secrets out of config files
- Connect your own devices with LLLanyard Pro
- Share LLLanyard across your devices or with your team
- Run scripts with API keys from Claude Desktop
- Keep keys out of Codex, Copilot, Gemini, Windsurf and Cursor
- Stop AI agents reading .env files and SSH keys