To remove a passphrase from an SSH private key, you use the ssh-keygen command with the -p flag, which lets you change or delete the passphrase. You will be prompted for the current passphrase, then asked for a new one — simply press Enter twice to leave it blank. This is a safe, reversible operation that only modifies the key file you specify, and it is the standard method on Linux, macOS, and Windows (OpenSSH).
Why SSH Keys Have Passphrases
An SSH key pair consists of a public key (safe to share) and a private key (secret). When you generate a key with ssh-keygen, you can protect the private key with a passphrase. This passphrase encrypts the private key file on disk, so if someone steals the file, they cannot use it without the passphrase. It is an extra layer of security beyond file permissions.
However, the passphrase is not sent to the server during authentication. It is only used locally to decrypt the key in your memory. The server only sees your public key. This means removing the passphrase does not change how the server authenticates you — it only affects how the key is stored on your local machine.
When Removing the Passphrase Makes Sense
There are legitimate reasons to remove a passphrase, and some situations where you should not. Consider the trade-off between convenience and security.
- Automated scripts and cron jobs: If a script needs to connect to a server without human interaction, a passphrase will block it unless you use an agent or a keychain. Removing the passphrase is a simple fix.
- CI/CD pipelines: Build servers often need to pull code or deploy. They typically use dedicated keys with no passphrase because there is no human to type it.
- Personal laptop with full-disk encryption: If your disk is already encrypted, the passphrase on your SSH key adds little extra protection. Removing it speeds up logins.
- Shared or less secure machines: If the computer is shared or not encrypted, keeping the passphrase is strongly advised. Removing it means anyone with access to your user account can use the key.
If you remove the passphrase, make sure the private key file has strict permissions (e.g., 600 on Linux/macOS) so only your user can read it.
Method 1: Using ssh-keygen (All Platforms)
The most direct way is to use the same tool that created the key. Open a terminal and run:
- Type
ssh-keygen -p -f ~/.ssh/id_ed25519(replace the path with your key file). - Enter the current passphrase when prompted.
- When asked for a new passphrase, press Enter without typing anything.
- Confirm by pressing Enter again.
The output will say Your identification has been saved and the passphrase is removed. The key file is rewritten in place, but a backup is not created automatically, so it is wise to copy the original first if you are unsure.
Method 2: Copy the Key Without a Passphrase
If you want to keep the original encrypted key and create a new unprotected copy, you can use ssh-keygen with the -p flag and specify different output files. For example:
ssh-keygen -p -f ~/.ssh/id_ed25519 -N "" -P oldpassphrase -y > ~/.ssh/id_ed25519_unprotected
This is more complex, and the -y flag outputs the public key, not the private. A simpler approach is to copy the key file first, then run the standard removal on the copy. This gives you both versions.
Method 3: Using ssh-agent (Alternative, Not a Removal)
If your goal is to stop typing the passphrase every time, you do not have to remove it. You can use ssh-agent to load the key into memory once, and it will provide the key for subsequent connections. On macOS, the Keychain integration can persist this across reboots. On Linux, you can add the key to your agent at login. This keeps the passphrase on disk while avoiding repeated prompts.
This is a better security posture than removing the passphrase entirely, especially on a laptop that might be stolen. The key file remains encrypted, and the passphrase is only needed once per session.
Common Mistakes and Pitfalls
- Wrong file path: If you specify a non-existent file,
ssh-keygenwill create a new key pair, not modify your existing one. Always double-check the path. - Forgetting to update the agent: If you have already added the key to
ssh-agent, the agent still holds the old decrypted key. You may need to remove it withssh-add -dand re-add it after removal. - Using the public key instead of private: The
-fflag must point to the private key (usuallyid_ed25519orid_rsa), not the.pubfile. - Permissions: After removal, if the key file is world-readable, SSH will refuse to use it. Set permissions to
600withchmod 600 ~/.ssh/id_ed25519. - Backup: If you remove the passphrase and then change your mind, you cannot restore it. There is no undo. Keep a backup copy of the original encrypted key.
Security Considerations
Removing a passphrase reduces the security of your private key to the security of your file system. On a multi-user system, any other user with read access to your home directory could copy the key. Even with 600 permissions, root or an attacker with your user session can read it. The passphrase is the last line of defense if the key file is exfiltrated.
If you use the key for high-value accounts (e.g., root access to production servers), consider keeping the passphrase and using an agent. If you must remove it, use a dedicated key that has limited permissions on the remote side — for example, a key that only allows a single command or a restricted shell. This limits the damage if the key is compromised.
Frequently Asked Questions
Will removing the passphrase change my public key?
No. The public key is derived from the private key’s mathematical properties, not the passphrase. The passphrase only encrypts the private key file. After removal, the public key on the server remains valid, and you do not need to update anything on the remote side.
Can I remove a passphrase from an SSH key on Windows?
Yes. If you have OpenSSH installed (built into Windows 10 and later), you can use the same ssh-keygen command in PowerShell or Command Prompt. The syntax is identical. For PuTTY keys (.ppk), you would use PuTTYgen instead — load the key, enter the passphrase, then clear the passphrase field and save.
What if I forgot the passphrase?
There is no way to recover or remove a passphrase without knowing it, because the private key is encrypted with it. You must generate a new key pair and replace the public key on the server. This is a good reason to keep a backup of the original key or use a password manager.
Is it safe to remove the passphrase for a GitHub or GitLab key?
It is common for developers to do this on their personal machines. The risk is that if your computer is compromised, the attacker can push code or access private repositories. Using an SSH agent with a passphrase is safer. If you remove it, ensure your account has two-factor authentication enabled as a second layer.
Does removing the passphrase affect SSH connections that are already established?
No. Established connections use the key already loaded in memory. The change only affects future connections that need to read the key file. If your agent has the key cached, you may not even notice the change until the agent is restarted.
Can I remove a passphrase from an encrypted key without typing the old one?
No. The tool needs the current passphrase to decrypt the key before it can rewrite it without a passphrase. There is no backdoor. If you lost the passphrase, the key is unusable and must be regenerated.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Podcasts to Boost Work Performance Career?
- What Network Does Mint Mobile Use?
- Wi-Fi Extender Making Network Worse? Real Fixes
- Why Earbuds Sound Bad on Calls & Fixes
- Google Check Grammar? How to Use It
- Dollar Gadget Desk Setup: Does It Really Work?