4

I'm trying to get TeamCity to build my private GitHub repository. I'm able to successfully get my VCS root to pass the connection test when I explicitly set the path to the key file; however, despite lots of Googling, I can't get it to work when I use the 'Default Private Key' option. I get com.jcraft.jsch.JSchException: Auth fail.

Both my TeamCity server and build agent are running as a user called (gasp) teamcity, and the contents of C:\users\teamcity\.ssh\ include both a config and a key file, where the config is pointing to the key file. My config contains:

Host *
    IdentityFile ~/.ssh/github.key

I've tried a variety of different path styles, both Windows and Unix style, but none seem to work.

Again, it works fine if I use the private key setting and explicitly set the path to the key file, but not when I use the default private key, which I apparently need for my build agent to work.

FMM
  • 4,289
  • 1
  • 25
  • 44

3 Answers3

4

Easiest solution for me was this:

  1. Upload your (OpenSSH) key under your Pipeline's project settings "SSH Keys" (as seen below):

    Pipeline - Project settings (ssh)

    Look at resource links for OpenSSH info (why/how)

  2. And then in VCS root settings, Update "Authentication Settings" as seen below:

    enter image description here

    • note: the username is; "git" (see 3rd resource)
  3. Make sure your "Fetch URL" look something like "git@bitbucket.org:ProjectName/RepositoryName.git" - (Note: Github equivalent is required here)

  4. Add your new key (see 1st resource)

Resources:

Aldracor
  • 2,133
  • 1
  • 19
  • 27
2

Git looks for the .ssh folder by forming a path with %HOMEDRIVE%/%HOMEPATH%. I've found that even though the %USERPROFILE% environment variable is set correctly these are not set. If %HOMEDRIVE% is empty %SYSTEMDRIVE% will be used instead so by default it will look for .ssh folder in c:\ (or whatever your system drive is).

You can check the environment variables an agent has via the agent parameters tab when selecting an agent and what a build is using via the parameters tab of the build.

Solution 1

create .ssh folder in c:

Solution 2

Set environment variables for %HOMEDRIVE% & %HOMEPATH% to match where your userprofile is

Solution 3

git also can use %HOME% environment variable this is the full path i.e. equal %USERPROFILE%

Community
  • 1
  • 1
JonSquared
  • 683
  • 6
  • 19
0

default private key also disabled when one use http://... url and not git@...

guai
  • 780
  • 1
  • 12
  • 29