October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

How to Stop SSH Asking for Your Key Passphrase at Every Login

Configure ssh-agent once, load your encrypted private key with ssh-add, and let OpenSSH reuse it. This guide covers macOS Keychain, Linux agents, host matching, socket failures, lifetimes and security trade-offs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

SSH asks for a key passphrase repeatedly when the private key is encrypted but no usable ssh-agent identity is available to the client. The durable fix is to run one agent per login session, load the private key into it with ssh-add, and configure OpenSSH to add the key automatically. On macOS, you can also store the passphrase in Keychain so the key can be restored after a restart. The private key remains encrypted on disk; only the agent holds the unlocked identity while it is running.

What the prompt means

An SSH key normally consists of a public key that you install on a server and a private key that stays on your computer. A passphrase encrypts the private-key file at rest. When SSH needs to authenticate, it must use the private key, so it asks for that passphrase if the key has not already been unlocked.

As an Amazon Associate I earn from qualifying purchases.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An authentication agent changes the workflow. ssh-agent is a background process that accepts an unlocked private key through its Unix-domain socket. Later SSH connections ask the agent to sign the login challenge instead of reading and decrypting the key file again. The passphrase is therefore entered once for the lifetime of that agent, rather than once per connection.

The agent does not automatically survive every reboot, terminal, remote session, or desktop login. If the current shell points to a different agent, or if the agent has no loaded identity, SSH has no cached key to use and prompts again. The environment variable SSH_AUTH_SOCK tells SSH and ssh-add which agent socket to use.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

One-time setup in any OpenSSH shell

First determine whether your current session already has an agent. A desktop environment, terminal application, or operating-system keyring may have started one for you. If no usable agent is available, start one and export its environment variables into the current shell.

  1. Start an agent when your session does not already provide one:
    eval "$(ssh-agent -s)"
  2. Load the private key that the server expects. Adjust the filename if you use another key type or location:
    ssh-add ~/.ssh/id_ed25519

    Enter the passphrase when prompted. This is the point at which the encrypted key is unlocked for the agent.

  3. Verify that an identity is loaded:
    ssh-add -l

    The command prints fingerprints for loaded keys. If it reports that no identities are available, the key was not loaded into the agent used by this shell.

  4. Connect normally:
    ssh [email protected]

    Subsequent connections that select this identity should use the agent without another passphrase prompt.

The identity lasts only as long as the agent keeps it. Closing the agent, ending a session that owns it, reaching a configured lifetime, or restarting the computer can require another ssh-add.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make OpenSSH load the key automatically

OpenSSH’s AddKeysToAgent client option tells the client to add a key and its passphrase to a running agent when the key is used. Put the setting in ~/.ssh/config:

Host *
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ed25519

With this configuration, the first connection that needs id_ed25519 asks for its passphrase and places the unlocked key in the agent. Later connections reuse it. The option does not create an agent by itself; a usable agent and SSH_AUTH_SOCK are still required.

A wildcard Host * applies the identity to every destination. If you use separate keys for work, personal systems, or different accounts, narrower host blocks are safer and prevent OpenSSH from trying an unintended key:

Host git.example.com
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ed25519_work

Host server.example.net
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_ed25519_server

Use the actual destination name you type in the SSH command. Aliases in the configuration are also valid, but the matching Host pattern must cover that alias.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

macOS: persist the passphrase with Keychain

Apple changed automatic agent loading in macOS 10.12.2. Its documented configuration uses UseKeychain yes to store the key passphrase in the macOS Keychain and AddKeysToAgent yes to load the key into ssh-agent. Add a matching block to ~/.ssh/config:

Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519

On the first use, macOS can retrieve the saved passphrase from Keychain and add the key to the running agent. This is the option that addresses prompts returning after a logout or reboot; AddKeysToAgent alone only helps while an agent still has the identity.

Load an existing key into the macOS agent

If the key is not present after changing the configuration, load it explicitly with the Apple-supported keychain option available in your installed macOS build:

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Enter the passphrase once. Then check the loaded fingerprints with ssh-add -l. Option names have varied across OpenSSH builds shipped with macOS, so verify support on the machine you are configuring with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ssh -V

If you maintain one configuration file shared with older OpenSSH versions that do not recognize UseKeychain, place this compatibility line before the option:

Host *
    IgnoreUnknown UseKeychain
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519

Use a narrower host block and a different IdentityFile when only selected destinations should use the stored passphrase.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Linux and other OpenSSH systems

Many Linux desktop sessions provide an agent through a session keyring or desktop component. Prefer that existing agent instead of starting a second one. In a minimal window manager, text-only login, container, or manually managed shell, start an agent with eval "$(ssh-agent -s)" and then run ssh-add.

Check whether your shell can reach the agent

printf '%sn' "$SSH_AUTH_SOCK"

A non-empty value should name a Unix socket. An empty value means the shell has no agent endpoint. A value inherited from another login can point to a socket that no longer exists or belongs to a different user session.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Load and manage identities

ssh-add ~/.ssh/id_ed25519
ssh-add -l

To clear every identity from the currently selected agent and start over, use:

ssh-add -D

That command removes keys from the agent; it does not delete or modify private-key files.

Why it still asks after you configured an agent

The shell is using the wrong agent

Multiple agents are common after opening a new terminal, entering a container, reconnecting over SSH, or restoring a desktop session. Compare SSH_AUTH_SOCK in the shell where you ran ssh-add with the shell where you run ssh. If they differ, load the key into the agent selected by the current shell or remove stale environment exports and start a clean session.

The key was never loaded

Run ssh-add -l. If the fingerprint is absent, load the actual private-key file with ssh-add path/to/private_key. Do not load the public .pub file; the agent needs the private key.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

The host block does not match

OpenSSH may be using a different identity than the one you configured. Ask the client to print its effective configuration for a destination:

ssh -G host.example | grep -i identityfile

Confirm that the resulting path is the encrypted private key you intended and that the Host pattern containing AddKeysToAgent applies to that destination. A block for server.example.com does not match an alias such as prod unless the alias is also listed.

The key has expired from the agent

AddKeysToAgent can specify a lifetime interval. When that interval ends, OpenSSH removes the identity automatically. If your configuration or desktop policy sets a lifetime, expect one more passphrase entry after expiry. Remove the lifetime restriction only if that persistence fits your security requirements.

The agent socket is inaccessible

The socket path can exist while permissions, user identity, or a terminated agent prevent access. Check the value of SSH_AUTH_SOCK, make sure the socket belongs to your current user, and start a fresh agent if the process behind it is gone.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A graphical prompt appears instead of a terminal prompt

SSH_ASKPASS and SSH_ASKPASS_REQUIRE control graphical passphrase prompting when no terminal is available. They do not cache a key and cannot replace an agent. Fix the agent connection and load the key; changing these variables only changes how a missing passphrase is requested.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

A practical diagnostic sequence

Run these checks in order in the same shell from which the failing SSH command is launched:

  1. Print the selected agent socket:
    printf '%sn' "$SSH_AUTH_SOCK"
  2. List identities in that agent:
    ssh-add -l
  3. Print the identity files that OpenSSH will consider for the destination:
    ssh -G host.example | grep -i identityfile
  4. If the list is empty or the wrong key is shown, load the intended private key:
    ssh-add ~/.ssh/id_ed25519
  5. Retry the connection. If it prompts only once and then works, the issue was a missing identity. If it prompts every time, compare the socket and agent between attempts, then inspect host matching and lifetime settings.

Security trade-offs of each approach

Stopping repeated prompts is a convenience decision, but it changes how long an unlocked identity remains usable. Compare the choices before applying a broad configuration.

Approach Private key encrypted at rest When the passphrase is entered Persistence Main exposure
Manual ssh-add Yes Once per agent lifetime Until the agent exits or the key lifetime expires Processes that can access the agent socket may request signatures
AddKeysToAgent yes Yes On first use by a matching host Until the running agent exits or the configured lifetime expires A broad Host * block can load more keys or destinations than intended
macOS UseKeychain yes plus AddKeysToAgent yes Yes Normally once when the key is first registered; Keychain can supply it later Keychain stores the passphrase; each running agent still has its own lifetime Anyone who can unlock the macOS account and access the keychain may obtain the convenience
Removing the key passphrase No Never Anyone with the readable private-key file can try to use it Loss or theft of the file immediately removes the passphrase barrier
FIDO security-key identity such as [email protected] Private material is held by hardware May require a PIN and/or touch Depends on the hardware and agent workflow Requires carrying and protecting the security key; it is a different authentication design

Agent caching keeps the private-key file encrypted on disk, but the unlocked identity is available to software that can use the agent socket. Protect your account, avoid sharing an agent socket with untrusted users or containers, and use host-specific configuration where practical. Do not remove a passphrase solely to eliminate prompts unless your machine’s threat model accepts an unencrypted key file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing the right configuration

You use one personal computer and one key

Use a running desktop agent, set AddKeysToAgent yes, and specify the exact key with IdentityFile. On macOS, add UseKeychain yes if you want the passphrase restored after restarting the computer.

You use several keys for different services

Create separate host blocks, each with its own IdentityFile. This avoids accidental key offers and makes it clear which key should be cached. Keep the patterns as narrow as the destinations require.

You work in short-lived shells, containers, or jump hosts

Expect to initialize an agent for each isolated environment, or deliberately forward an existing agent only when the intermediary is trusted. A new shell with no inherited SSH_AUTH_SOCK cannot see identities loaded into an agent elsewhere.

You need automatic expiration

Configure an agent or AddKeysToAgent lifetime so identities disappear after a defined interval. This reduces the window in which a stolen session can use the cached key, at the cost of another passphrase prompt when the interval ends.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What not to change

  • Do not replace a private-key path with its .pub file; authentication signatures require the private key or an agent holding it.
  • Do not assume SSH_ASKPASS solves repeated prompts; it controls prompt delivery, not key storage.
  • Do not add every key to a global agent without checking which programs and sessions can reach its socket.
  • Do not delete the passphrase from a valuable key merely because an agent was not configured correctly.
  • Do not copy a macOS-only UseKeychain setting into an older or non-Apple OpenSSH client without checking option support; use ssh -V and IgnoreUnknown UseKeychain where a shared file requires compatibility.

After the fix: a quick verification checklist

  • SSH_AUTH_SOCK is non-empty in the shell that runs SSH.
  • ssh-add -l shows the expected fingerprint.
  • ssh -G destination shows the intended IdentityFile.
  • The matching Host block includes AddKeysToAgent yes.
  • On macOS, UseKeychain yes is present only where supported and the key was registered with the Apple keychain option when needed.
  • A configured lifetime has not expired.
  • The private key still has its passphrase and remains protected on disk.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.