Always having to enter passphrase for ssh key for git
So I've started using git and github recently, and I got tired of constantly entering my credentials, so I attempted to set up an SSH key authentication using these instructions.
Now, it seems to work for the most part, but I seem to have to enter my SSH passphrase quite often. Anytime I open a terminal and attempt to access it, it prompts me (sometimes as soon as I navigate to the directory with a repo).
I'd like to be able to just login (I use lightdm and herbstluftwm if this makes any difference) and have it work. Any advice as to what's going on or what I need to look at? Thanks in advance.
Also, is there any better place I should post this, should I not find any answers here?
About this post
- Posted
- Archived
- Score
- 1 · 100% up
- Kind
- Text
- ID
- 2vl385
9 comments
Look into using a ssh agent.
This. Learn SSH.
https://wiki.archlinux.org/index.php/SSH_keys#SSH_agents
Everyone here is recommending an ssh agent (and that will probably work), but here is an alternative that is imo simpler: SSH ControlMaster. What the following config options will do is actually cache/keep open all SSH connections for however long you specify (Google it for a better/more detailed explanation).
If you don't want this enabled for all of your ssh connections, change the "*" above to "github.com". Also change the "10m" to however long you think is appropriate. So instead of caching your credentials, this persists the connection. (As a side effect, if you don't push/pull anything for a while you will see a timeout message, but this can be ignored. Simply means that next time you push/pull you will need to login again.)
As others have suggested, try using an ssh-agent.
Here's an example of what I typically do, I find it works well. I use tmux and have this in my .tmux.conf:
When I start my terminal, I'll unlock my keys and add them to my agent.
Then I start a new tmux session, if I need to close the terminal for any reason, I just detach the tmux session. When I re-attach, my keys are still unlocked.
Change your config.
This is a pretty good article.
https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2
I just removed the password from my ssh key since my home is encrypted anyways.
Which is fine, if you don't care about your private key sitting on your computer in plain text.
If you aren't using home encryption, then the rest of your files are sitting there in plaintext too. There's not much reason to double encrypt your ssh key unless you leave your computer on and unattended in public, which is kind of hard to do on a desktop.