A developer uses a security key to manage time-limited SSH access and connect to an internal network.
An SSH key can have a strong passphrase and still be available for hours after you type it. That’s the convenience of ssh-agent: it signs authentication requests without making you unlock the key file for every connection. The trade-off is that a process with access to the agent can request a signature without knowing that passphrase. Shattered’s 12-step walkthrough tackles that gap. The most useful changes are to load fewer keys, give them a deadline, and stop forwarding the agent through routine jump hosts.

OpenSSH’s upstream release notes list Portable OpenSSH 10.6p2, released November 5, 2026, at the top. That’s an upstream release, not a minimum requirement for this guide or a description of what ships with Windows 11. In particular, the version printed by ssh -V identifies the client you invoked; it doesn’t prove that the agent it talks to enforces a lifetime or confirmation prompt. Test those controls with a disposable key before trusting them with production access.

A developer uses a security key to manage time-limited SSH access and connect to an internal network. 1–4: Identify your agent and make a test key​

  1. Check which tools you’re using. Run ssh -V and ssh-add -l. On Linux and macOS, printf '%s\n' "$SSH_AUTH_SOCK" shows the socket path in the current shell. On Windows, Get-Command ssh, ssh-add -All helps identify competing copies. “The agent has no identities” is a reachable agent with an empty list, not a connection failure. If ssh-add lists your key but Git still asks for a passphrase, GitHub documents a common cause: Git for Windows may be using its bundled SSH client instead of the Windows OpenSSH client that talks to the service.
  2. On Linux, reuse the session agent if it works. Don’t start another one from every shell profile. If you manage your own systemd user service, OpenSSH’s -D keeps the process in the foreground for supervision, -a selects a socket, and -t sets a default lifetime. For example, the service can run ssh-agent -D -a %t/ssh-agent.socket -t 4h, using the actual executable path in ExecStart. Point the shells that should use it at $XDG_RUNTIME_DIR/ssh-agent.socket, then verify from a fresh terminal. The agent’s default is not a hard cap: an explicit lifetime on an individual key overrides it.
  3. On Windows, start the service; on macOS, check the existing agent. Microsoft documents the commands below for the Windows OpenSSH Authentication Agent. Run them in elevated PowerShell, then list and load keys from your normal user shell. Automatic startup is optional. On macOS, start with ssh-add -l; leave off Apple’s --apple-use-keychain while testing so you don’t mix passphrase storage with the question of how long the identity stays loaded.
    Code:
    Set-Service -Name ssh-agent -StartupType Automatic
    Start-Service ssh-agent
    Get-Service ssh-agent
  4. Generate a disposable key. Run ssh-keygen -t ed25519, choose a new filename such as id_ed25519_lab, and set a passphrase. Install only the .pub file on a host you control. If you’re changing server access, keep a working administrative session open. Test a fresh login with -o IdentityAgent=none -o IdentitiesOnly=yes -i PATH_TO_LAB_KEY to establish that the key works from disk before adding the agent to the equation.

5–8: Put expiry and confirmation to the test​

  1. Load one named key with a short test lifetime. On a compatible agent, run ssh-add -t 60 ~/.ssh/id_ed25519_lab, then ssh-add -l. In native PowerShell, use "$env:USERPROFILE\.ssh\id_ed25519_lab" for the path. Avoid bare ssh-add: it tries a list of default identity files, which may include keys you didn’t intend to load.
  2. Check that the agent signs, then check that the key disappears. While the key is loaded, use ssh -v for a fresh connection to the test host and look for the lab fingerprint marked as an agent identity and a successful public-key login. After a minute, run ssh-add -l again; that fingerprint should be gone. Don’t use an existing or multiplexed connection to test expiry: removing a key prevents future use by the agent, not use of a session that has already authenticated. A new login may also succeed by reading the key from disk. If a constrained load is rejected or the fingerprint sticks around, don’t count on the timeout. Microsoft’s Win32-OpenSSH tracker documents a Windows build rejecting bounded-lifetime loads; Microsoft’s service setup instructions establish how to load a key, not that the service enforces -t.
  3. Try confirmation for sensitive keys. On an agent that supports it, reload the lab key with ssh-add -c -t 30m ~/.ssh/id_ed25519_lab. OpenSSH uses an ssh-askpass helper for agent confirmation. Test both denial and approval on fresh connections and check the verbose output for fallback to another identity. If your desktop can’t display the prompt or the agent rejects the constraint, don’t quietly load that same sensitive key without it. Use a passphrase-protected key directly or a compatible hardware-backed workflow instead.
  4. Make host-specific settings explicit. Put specific Host blocks above Host *: OpenSSH normally uses the first value it obtains for a setting. In the example below, automatic timed loading is opt-in for lab, not a blanket policy. Use AddKeysToAgent no for that host if your agent doesn’t enforce expiry. IdentitiesOnly yes limits what the SSH client offers; it doesn’t stop a different process from asking the agent to sign. Run ssh -G lab to inspect the effective settings.
    Code:
    Host lab
        HostName lab.example.com
        User testuser
        IdentityFile ~/.ssh/id_ed25519_lab
        IdentitiesOnly yes
        AddKeysToAgent 30m
    
    Host *
        ForwardAgent no
        AddKeysToAgent no

9–12: Add hardware, avoid forwarding, and verify the result​

  1. Use a FIDO2 key where it earns its keep. With a compatible client, authenticator, and server, try ssh-keygen -t ed25519-sk -O verify-required and save it under a new filename. Unlike a software key, it has a device-specific secret that stays on the authenticator; the local file holds a handle and should still be protected. Touch proves presence, while verify-required requests user verification, such as a PIN. They aren’t the same. Test the full login on your actual build and enroll a separate backup credential before relying on the token. If you deliberately generate a resident credential with -O resident, ssh-keygen -K can recover its handle files to the current directory on a replacement machine.
  2. Use ProxyJump for the bastion. For an authorized destination behind a jump host, set ProxyJump bastion in the destination’s Host block and leave ForwardAgent no in effect for both aliases. Your local client handles authentication to the destination through the jump host; the jump host relays the connection without receiving access to your agent. It can still see connection metadata. Verify both aliases with ssh -G, and don’t override the setting with ssh -A.
  3. Remove keys when you’re done. ssh-add -d PATH_TO_KEY.pub removes one identity; ssh-add -D removes them all from the selected agent without deleting key files. If your agent supports it, ssh-add -x locks it and ssh-add -X unlocks it. On Unix-like systems, check the ownership and access permissions of the socket and its containing directory; a private path isn’t a barrier against another process running as your user. If forwarding is unavoidable, OpenSSH 8.9 introduced ssh-add -h destination constraints. They depend on compatible components across a forwarded connection and limit where a key can be used, not who can reach the socket. Don’t assume the Windows client accepts the option: the Win32-OpenSSH project tracker records builds that reject it.
  4. Make the checks repeatable without calling them an audit. A local checklist can record ssh-add -l and use ssh -G to flag unexpected ForwardAgent, IdentityFile, or AddKeysToAgent settings for the aliases you actually use. On Unix it can also check socket ownership and key-file permissions; on native Windows, check the service and file ACLs instead of applying Unix mode-bit rules. Shattered’s sample script is useful for spotting drift, but neither its output nor an hourly timer proves a loaded key has a deadline. AddKeysToAgent no doesn’t mean keys never expire: an explicit ssh-add -t or the agent’s own default can still set a lifetime. The short load-and-recheck test is what verifies expiry on your setup.

If the agent can’t be reached, check the service or socket before touching the key. If the agent lists the right fingerprint but a fresh login fails, check the remote username, the installed public key, and the effective identity settings with ssh -G; then use ssh -v to see what the client actually offered. The goal isn’t to make every login prompt-free. It’s to know which key can sign, for how long, and whether any remote machine can ask it to.

 

References

  1. ssh-add Setup: Lock Down ssh-agent in 12 Steps, 60 Min - shattered.io shattered.io 2026-11-29T01:37:20+00:00
  2. Key-Based Authentication in OpenSSH for Windows | Microsoft Learn learn.microsoft.com
  3. ssh-agent(1) - OpenBSD manual pages man.openbsd.org