Connect Claude Code or Codex to a Raspberry Pi Without Sharing Your Password A developer walkthrough shows how to give terminal-capable coding agents like Claude Code and Codex CLI SSH access to a Raspberry Pi using dedicated Ed25519 key pairs and ssh-agent, so the Pi's account password never passes through the model's prompt, scripts, or tool arguments. The setup is run manually outside the agent conversation, with host-key fingerprint verification and a note that key-based access still grants the remote account's full permissions rather than read-only access. You want a coding agent to check a service on your Raspberry Pi. It needs to run a command over SSH, and the connection asks for a password. Pasting that password into the conversation is an unnecessary step. Configure SSH authentication yourself, then let the agent invoke the SSH client. The client can authenticate without putting the Pi's password into a prompt, a script, or a tool argument. SSH keys are the right approach here. Raspberry Pi's own remote access documentation https://www.raspberrypi.com/documentation/computers/remote-access.html describes key-based authentication for connections that don't require entering the account password each time. There is a boundary worth understanding before setting this up: the agent will still be able to run commands with the remote account's permissions. Keeping a password out of the conversation does not make that access read-only. For this walkthrough, assume Claude Code, Codex CLI, or another terminal-capable coding agent runs on your computer. That computer can already reach the Pi over your local network. The commands below use a Linux, macOS, or WSL shell with OpenSSH installed, and the Pi runs Raspberry Pi OS with SSH enabled. The connection follows this path: The SSH client handles authentication locally; the remote account determines what commands can do. With public-key authentication, SSH proves possession of the private key without sending that key to the server. A local ssh-agent can hold the unlocked identity and perform the authentication operations for the client. The language model does not need the private key contents or its passphrase. See the OpenSSH documentation for SSH authentication https://man.openbsd.org/ssh and ssh-agent https://man.openbsd.org/ssh-agent . A cloud coding session is a different environment. It does not automatically inherit your laptop's SSH configuration, agent socket, or access to a private LAN. Start with a local CLI for this workflow. Run the setup commands yourself in a terminal outside the coding agent's conversation. Replace labuser and 192.168.1.50 throughout with your Pi's actual username and address. labuser is an example, not a default Raspberry Pi account. On your computer: ssh-keygen -t ed25519 -f ~/.ssh/pi lab ed25519 -C "pi-lab-access" Choose a passphrase when prompted. If the filename already exists, stop and choose another name rather than overwriting a key. This produces two files: ~/.ssh/pi lab ed25519 : the private key, which stays on your computer. ~/.ssh/pi lab ed25519.pub : the public key, which you install on the Pi. A dedicated key makes this connection easier to identify and revoke without changing unrelated SSH access. You may have seen an example using ssh-keygen -t ed25519 -b 4016 . Remove the bit-length argument: Ed25519 has a fixed key length, and OpenSSH ignores -b for this key type https://man.openbsd.org/ssh-keygen . Copy only the public key: ssh-copy-id -i ~/.ssh/pi lab ed25519.pub labuser@192.168.1.50 This bootstrap step may ask for the Pi account password. Enter it directly into your own terminal. You are authenticating with SSH, without passing the password through the coding agent. On the first connection, verify the Pi's host-key fingerprint before accepting it. From a trusted local console on the Pi, you can display its Ed25519 host-key fingerprint with: ssh-keygen -lf /etc/ssh/ssh host ed25519 key.pub Compare that fingerprint with the one presented by your client. If the client presents a different host-key algorithm, compare the corresponding host public key. Host-key checking helps establish that you reached the intended server; keep it enabled. OpenSSH explains this in its host-key verification guidance https://man.openbsd.org/ssh VERIFYING HOST KEYS . If ssh-copy-id is unavailable, use Raspberry Pi's manual public-key installation instructions https://www.raspberrypi.com/documentation/computers/remote-access.html . Preserve existing entries in authorized keys when adding yours. Check whether your shell already has access to an authentication agent: ssh-add -l If it reports that it cannot connect to an authentication agent, start one in this shell: eval "$ ssh-agent -s " Then load the key for one hour: ssh-add -t 1h ~/.ssh/pi lab ed25519 Enter the key passphrase in this terminal. OpenSSH's ssh-add documentation https://man.openbsd.org/ssh-add covers both interactive passphrase entry and the identity lifetime option. The distinction between the two passwords matters. The Pi account password protects account login. The key passphrase protects your private key on disk. You can keep that passphrase and still let subsequent SSH commands authenticate without prompting while the identity is loaded. Launch your coding CLI from this shell so its subprocesses can inherit SSH AUTH SOCK , the environment variable that identifies the authentication agent's socket. An already-running application may have a different environment. Add this host entry to ~/.ssh/config on your computer, before broad Host defaults: Host pi-lab HostName 192.168.1.50 User labuser IdentityFile ~/.ssh/pi lab ed25519 IdentitiesOnly yes PreferredAuthentications publickey BatchMode yes StrictHostKeyChecking yes ForwardAgent no IdentitiesOnly limits which identities SSH offers. BatchMode disables interactive authentication and confirmation prompts, so an unattended command fails instead of waiting for input. Strict host-key checking requires an already trusted host key. Agent forwarding is unnecessary for running commands on this Pi. These options are documented in the OpenSSH client configuration reference https://man.openbsd.org/ssh config . Example configuration for the pi-lab alias. Keep the copyable configuration above when adapting it to your machine. Before connecting, inspect the resolved settings with ssh -G pi-lab . This prints configuration without opening a remote session. The capture below uses -F ./ssh-config to inspect an isolated example file, so it does not depend on personal SSH settings. Actual local OpenSSH output, typeset as a console capture. The hostname and username are examples; this is a configuration check, not a successful Pi login. Test the alias yourself: ssh pi-lab 'hostname; whoami; uptime' Only proceed when this works without a password prompt. If authentication fails, check the public-key installation, username, loaded identity, and agent environment. A host-key failure needs verification, rather than a flag that bypasses the check. Start your preferred CLI from the prepared shell: claude Or, for Codex CLI: codex Then give it a bounded first task: The Raspberry Pi is available through the SSH alias pi-lab. Authentication is configured locally. Do not read or print private keys, request passwords, or change SSH configuration. Run this diagnostic command: ssh pi-lab 'hostname; whoami; uptime; df -h /' Report the results. Ask before changing files, installing packages, restarting services, or using sudo. The alias is enough connection information for the agent to invoke SSH. Its execution environment must still permit the network connection and access to the authentication socket. If a sandbox blocks either, review the specific restriction; successful SSH in your terminal does not establish that every agent subprocess has the same access. Claude Code documents its permission controls https://code.claude.com/docs/en/security and shell sandbox restrictions https://code.claude.com/docs/en/sandboxing . Keep approvals scoped to the task rather than granting unrestricted shell access just to make a connection work. Consider the diagnostic command above. Its output includes a hostname, username, uptime, and disk usage. Later, you might ask for application logs, which could contain tokens or customer data. Treat output returned to the coding agent as material that may enter the model's context. Also consider the account itself. A separate non-administrator account gives you a clearer starting point than your normal administrative login. Check its group memberships and sudo permissions: a new username does not establish limited access by itself. An SSH key authorizes whatever that remote account is allowed to do. A prompt asking for read-only behavior is useful task guidance, but enforce stronger restrictions through remote permissions or, for narrow automation, a forced command in authorized keys . OpenSSH documents per-key restrictions and forced commands https://man.openbsd.org/sshd AUTHORIZED KEYS FILE FORMAT . Likewise, ssh-agent is an authentication mechanism, not a barrier against every process running as your local user. A process with access to its socket can request authentication operations. If you need the private key to be inaccessible to the coding agent, enforce that with filesystem isolation, a separate user, or a hardware-backed key. Simply leaving the key outside the repository does not establish that boundary. This is separate hardening, not a prerequisite for keeping the password out of the conversation. After key authentication works, keep an existing session open and retain a recovery route, such as a local console. On the Pi, configure these directives in the appropriate global SSH server configuration: PubkeyAuthentication yes PasswordAuthentication no KbdInteractiveAuthentication no Keyboard-interactive authentication is a separate mechanism that can also prompt for a password. Check included configuration files and Match sections, which can affect the settings that apply to your connection. See the SSH server configuration reference https://man.openbsd.org/sshd config . Validate the configuration before applying it: sudo /usr/sbin/sshd -t You can inspect effective settings with sudo /usr/sbin/sshd -T ; connection-specific Match rules require the appropriate -C connection parameters. Both validation modes are described in the sshd manual https://man.openbsd.org/sshd . If validation succeeds, reload the service on Raspberry Pi OS: sudo systemctl reload ssh Open a second connection from your computer and confirm key authentication still works before closing the original session. For a local Pi project, I would start with a dedicated key, a limited remote account, and one diagnostic command. That is enough to establish the workflow. Expand the account's permissions only when the next task requires them, and keep credential setup in your own terminal.