1

The software context here is Windows 10 + Git for Windows, which comes with a lot of extra tools, some of which I mention below.

I have several private repositories on BitBucket. In order to to avoid having to constantly use my credentials when cloning/pulling/pushing to these repositories, I created a default SSH-key with ssh-keygen and then loaded the key into BitBucket.

Now, in Git-Bash, in order for this to work, I have to run:

$ eval $(ssh-agent)
Agent pid 11904

$ ssh-add ~/.ssh/<private_ssh_key_file>
Enter passphrase for <private_ssh_key_file>:
Identity added: <private_ssh_key_file>

After this, everything works as expected: I can work with my git repositories without having to type any credentials.

The inconvenience is that I have to do this every time I reboot the system.

Is there some way to automate this and make it run automatically on every system-start (user-login) ?

I was thinking of writing some bash-script to do this and somehow add it to Windows' startup list, though I doubt it supports bash. Also, the part that is probably the most difficult is how the script should actually provide the "passphrase" to ssh-add when it asks for it.

Does anyone have any idea how to do this?

4
  • I assume your not willing to place the passphrase in the script itself? There are SSH clients that will allow you to use a certificate for authentication and it will remember the password. However, are you willing to give up the security benefits of inputting the passphrase everytime you reboot for the convenience of doing it automatically?
    – Ramhound
    Commented Dec 31, 2018 at 8:35
  • @Ramhound Yes, in this case, the convenience of automation is more important. So it's fine if I add the passphrase in the script itself. Commented Dec 31, 2018 at 8:38
  • Have you considered using a password-less ssh key?
    – Mark Woon
    Commented Apr 1, 2019 at 19:47
  • @MarkWoon I guess that could work. Though it significantly lowers the security of the whole thing. I’ll give it a try though. Commented Apr 2, 2019 at 11:56

0

You must log in to answer this question.

Browse other questions tagged .