sighlighted scribble sircled

Remember SSH Passphrase for Git on Ubuntu on Windows

October 09, 2016

icon-expand icon-expand

Having to constantly retype your SSH private key passphrase to use Git is annoying, and there are a number of articles out there about how to get around the issue.


Problem is, most of the recommendations on the Windows side assume you’re using Git Bash, so you’re only using the shell emulator for Git. They haven’t been updated for Ubuntu on Windows* where you are probably using Bash for lots of things, not just Git, and it would be just as annoying to have to enter your SSH private key passphrase every time you open Bash as it would be to have to enter your passphrase every time you use a Git command.

The solution:

  1. Create a shell script in your home directory. I called mine sshagent.sh vi sshagent.sh
    (or nano sshagent.sh, etc.)
  2. Paste in the code to spin up your SSH agent Note that those are tic marks in the first line, not apostrophes.
    eval `ssh-agent -s`
  3. Make the script executable chmod +x ~/sshagent.sh
  4. Extra important – you have to run the script in your current shell a. This tripped me up for a while. If you were to run this as a regular Bash script using ./sshagent.sh or ~/sshagent.sh, it’ll execute as its own program, and your current interactive terminal won’t know about it. b. You can read more about this method here:
    http://unix.stackexchange.com/questions/43882/using-to-execute-files-in-bash ~/sshagent.sh

(That is dot space and then your file path and name. Dot space dot slash sshagent.sh would work as well if you’re currently in your home directory  . ./sshagent.sh)


Now, you can start Bash normally, and it won’t bug you about your SSH passphrase at startup.  If you do need to use Git, you can run your little script with . ~/sshagent.sh
It’ll ask for your passphrase, and then you won’t have to mess with it again.
And that is how you spend hours consolidating two commands into one. Happy coding!

* Ubuntu on Windows is probably the greatest decision Microsoft has made since Windows 7. If you aren’t using it, you should.

Jeff Robertson

Jeff Robertson is a digital marketer and an online development expert with experience stretching back to dial-up. He is partner and Chief Technology Officer at Gravity, where he helps bridge the gap between the technical and marketing worlds, as well as oversees technical infrastructure.

Latest Blogs

icon blog-grid

Could an icon be right for your brand?

Read Post
Read post
icon blog-grid

There’s a reason the history books aren’t full of famous rule followers

Read Post
Read post
highlight highlight



This e-mail was sent from Gravity Global (https://www.gravityglobal.com/)

Blog Home
The Secret to a Killer Panel Discussion at your Next Conference
Finding the Right Balance Design, UX and SEO