Reputation: 4329
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.
Upvotes: 4
Views: 7544
Reputation: 805
default private key
also disabled when one use http://...
url and not git@...
Upvotes: 0
Reputation: 2181
Easiest solution for me was this:
Upload your (OpenSSH) key under your Pipeline's project settings "SSH Keys" (as seen below):
Look at resource links for OpenSSH info (why/how)
And then in VCS root settings, Update "Authentication Settings" as seen below:
- note: the username is; "git" (see 3rd resource)
Make sure your "Fetch URL" look something like "[email protected]:ProjectName/RepositoryName.git" - (Note: Github equivalent is required here)
Add your new key (see 1st resource)
Resources:
Upvotes: 4
Reputation: 683
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.
create .ssh folder in c:
Set environment variables for %HOMEDRIVE% & %HOMEPATH% to match where your userprofile is
git also can use %HOME% environment variable this is the full path i.e. equal %USERPROFILE%
Upvotes: 2