Question

I have a set of web servers, and to keep the files up to date on the server, I use a windows scheduled task. The task calls a batch file which executes a git-pull command.

This seems simple enough, but I use SSH keys to authenticate to the git server. So far, the only method I have been able to figure out to pass these keys to git is to use pageant.exe. As a result, my batch file contains the following commands:

"C:\Program Files\TortoiseGit\bin\pageant.exe" "C:\privateKey.ppk"
set local
set HOME=c:\
set GIT_SSH=C:\Program Files\TortoiseGit\bin\TortoisePLink.exe
cd c:\webserverfiles
git pull -v --progress origin master

This works for the most part; however, a major issue is that pageant runs in the background, and on the first execution of this batch file, the first line hangs indefintely. To work around this, I manually run the task, kill it, then let it run automatically afterward. But, if pageant crashes or the server is rebooted, my files no longer synchronize on that server because of the first-line problem (which could be a big problem in a round-robin scenario).

Are there any suggestions as to how to improve this scheme? I cannot switch to https-based git.

Was it helpful?

Solution

I don't recognize the situation that you would have to make special environment settings to make Git commands work. Are you sure you have it set up the right way?

I usually recommend that developers to

  1. Install msysgit
  2. Install TortoiseGit.
  3. While installing TortoiseGit, they should choose OpenSSH (not TortoiseGitPLink). enter image description here
  4. Run ssh-keygen.exe -C "firstname.lastname@domain.com" to generate keys in the $HOME\.ssh folder
  5. Copy the public key in .ssh\id_rsa.pub to the Git server.

OpenSSH does not require pageant.exe.

After this setup, no extra environment settings are needed. (SSH_AGENT_PID and SSH_AUTH_SOCK variables are set up by the frameworks). git clone ssh://xxxx should work right away.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top