SSH keys aren't being used for custom Unity packages
Our Unity project uses SSH to pull down some packages from git: https://docs.unity3d.com/Manual/upm-git.html#Git-SSH
I've added a key on the build machine to the SSH agent and when opening the project on the build agent or running batch mode locally via command line, everything works fine, but when trying to create a build from TeamCity using the Unity build step the build fails with the error:
Error when executing git command. Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
The SSH key used to pull the repo via VCS is the same key that exists on the build machine, and I've tried initializing an agent and adding the SSH key manually through powershell in another step with no luck.
Any help would be really appreciated.
Please sign in to leave a comment.
Did you try adding the host to the 'known_hosts' file on the agent?
See the following link for more details:
https://stackoverflow.com/a/13364116
Hey Mikhail,
It's present and added on the build machine (otherwise we wouldn't be able to open the project locally and pull down packages) does it need to be added separately to the build agent itself in any way?
No, I meant the agent machine, not the agent process itself.
Please provide the entire build log downloaded from the UI. You can upload it here: https://uploads.jetbrains.com. Let me know the upload ID once done.
Yeah unless I'm misunderstanding the agent machine has no SSH problems and itself can connect, only when executed via TC do we have any issues.
Here's the ID: 2023_02_17_FK1jhWQxvSFFowrGv7dGY7
Let me know if there's anything else I can provide
known_hostsfile, or the key itself is incorrect. In your case, since you mentioned that the host is present inknown_hosts, we can assume that the Unity process is working with a different SSH config. The SSH config can be defined on two different levels: user and global. On Windows, I believe it should be located inC:\Users\username\.sshandC:\ProgramData\sshaccordingly. The target host should be present in theknown_hostsfile for the user that runs the TeamCity agent. Could you please double-check that?Hi Mikhail,
I've tried what you've suggested and unfortunately still no luck. The ssh keys/known hosts exist in both the user level and the global level. I've also tried adding the ssh key via the `nt authority/system` user, this still didn't fix the issue.
As mentioned above running the step locally succeeds with no issues.
Just to confirm, did you try using the same command line that is used in the build step to start the step locally as I suggested in my previous message? Did it succeed?
I did try it, it worked locally.
Hi Janek,
Could you please attach the log with the output from the CLI execution of the above-mentioned command? Just in case, the command should be executed on the same machine where the agent runs and using the same user that runs the agent. Not on your local workstation.