Search code examples
linuxpowershellsshssh-keysopenssh

How do you avoid typing the password of your ssh key each time, on Linux and Windows with OpenSSH?


I use a password-protected ssh key (RSA). That means that I need to type the password to decipher the key before using it.

I noticed that on some computers, I don't need to type the pass of my ssh key each time I need to use it.

On my Windows computer, as well as some Linux servers, I need to do it.

I use OpenSSH on Windows (not Putty), so it is the same key as Linux. Stored in the /.shh directory.

Having a password-protected key is good in case someone steals it. But typing the password each time is annoying.

Is there a way to have my computers, on Windows and Linux, remember it?

I use it from the shell (default Ubuntu terminal and PowerShell, often from VS Code).

Thanks

I tried this, but no success:

(base) PS C:\code> ssh-add -k C:\Users\user\.ssh\id_rsa  
Enter passphrase for C:\Users\user\.ssh\id_rsa: 
Identity added: C:\Users\user\.ssh\id_rsa (C:\Users\user\.ssh\id_rsa)
(base) PS C:\code> git fetch
Enter passphrase for key '/c/Users/user/.ssh/id_rsa': 
🤬🤯🥴

Solution

  • ssh-agent is the process that keeps your passphrase after the initial unlocking, so you don't need to type it every time

    Linux Basic Tutorial on ssh-agent

    Windows SSH documentation

    Git Bash for Windows documentation