Before upgrade
When I was running git clone git@...
(using ssh) once per computer restart a window dialog appeared containing a textbox for inserting my SSH passphrase and confirmed with OK. Then the passphrase was no longer required until the next start of my system.
After upgrading to 13.10
After upgrading to Ubuntu 13.10 that window doesn't appear anymore but a message in terminal appears:
Enter passphrase for key '/home/username/.ssh/id_rsa':
...every time when cloning a git repository this appears.
How can I fix this? I want to enter my passphrase only once.
Anyway running the following commands the problem was fixed for me:
How to fix
I fixed this by entering the following commands:
This creates a new bash process that allows you to add private keys. When adding a new private key you will be prompted for the passphrase once and only once.
And then:
...where
username
is your username. You can do the same using$USER
variable:Alternatively, just use
~
for your home directory.And the problem was fixed.
Short answer
Use AddKeysToAgent and add the following to your
.ssh/config
at the beginning:and run git/ssh/... If it's not enough, check your ssh version and check that ssh-agent is loaded with these instructions:
1) Check the openssh version
Firstly check that your ssh version, it must be greater of equal to 7.2:
2) Edit the config file
If it's the case just add in your
.ssh/config
one line at the beginning:Other options are
no
(the default),yes
,confirm
(optionally followed by a time interval),ask
or a time interval.3) Check if ssh-agent is already open
Usually distributions automatically load an ssh-agent. To check it, run
If you don't see any line containing it, you need to load it by running:
Note that this enable the agent only on the current terminal, so to enable it everywhere, you can try to add this line in your
~/.profile
file and reboot.This Atlassian document (archive.org backup) fixed the issue for me on Ubuntu 14.04 Server Edition:
Just add this values into your
.bashrc
file:And after logging in, it asks for password only once and it caches. You don't need to enter it each time.
A workaround for this bug is to add the following to the bottom of
~/.bashrc
Users of the fish shell can use this script to do the same thing.
I've spend far too long to get it running on WSL2 Ubuntu 20.04. Finally, we need to start ssh-agent on spawning new console, but don't load a key then. Load key upon first usage and use
AddKeysToAgent
.Add following at the end of your
~/.bashrc
or~/.zshrc
:And add following at the end of
~/.ssh/config
file:I use this:
If you use azure .ppk file
Just convert it to pem and add permission 400 with simple steps:
On Ubuntu 18.04, the ssh-agent is started when the session X is opened, it is managed in the file /etc/X11/Xsession.options:
Alternate solution is use keychain.
Man page.