dx_over_dt
dx_over_dt

Reputation: 14318

Configuring SSH keys for git to use when not in Git Bash

I'm fairly new to git and have rarely used anything but Windows for programming.

I've set up a React app using create-react-app, and used gh-pages to deploy it to my github.io project page. I've set up an SSH key on my local machine and added it to my github SSH Keys. Running ssh-agent and ssh-add makes deploying in Git Bash simple without having to enter a username and password. Great.

However, I'm using Sublime Text for my development, and want to use the npm plugin to run npm run deploy right from the editor. I get the following error:

Cloning [email protected]:<username>/<repo>.git into node_modules\gh-pages\.cache
Cloning into 'node_modules\gh-pages\.cache'...
Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Unless I miss my guess, it appears that git doesn't know to use the SSH key automatically, regardless of where it's being run from. Is there a way to configure this?

Upvotes: 1

Views: 544

Answers (1)

VonC
VonC

Reputation: 1326746

Make sure to define in your environment variable:

  • a PATH which includes <git>/bin as well as <git>/usr/bin (with <git> the installation path for the latest Git For Windows)
    (usr/bin does include ssh.exe);
  • a HOME environment variable set to your %USERPROFILE%

Make sure that you see your public/private key in dir %HOME%\.ssh

Then launch SublimeText from that session.

Upvotes: 1

Related Questions