On a freshly installed Win11, we configured the following:
Remove windows native OpenSSH (via DISM) and confirmed it was really removed
Install OpenSSH 8.0.0.1 via chocolatey, with ssh-agent
Configured GIT_SSH to point to the installed ssh.exe
Confirmed GIT_SSH is available inside Unity custom builder by printing out the environment variable
Installed git from chocolatey
Added a suitable SSH key to $HOME/.ssh/id_rsa.ORIG (with no password)
The following configs were enabled independently at different times to allow for testing (both failed):
copy $HOME/.ssh/id_rsa.ORIG to $HOME/.ssh/id_rsa and tested using ssh -v git@gitab.com
add $HOME/.ssh/id_rsa.ORIG to ssh-agent and test using ssh-add $HOME/.ssh/id_rsa.ORIG && ssh-add -l
For each of the 2 scenarios above (id_rsa and ssh-agent) we confirmed that the key could be used to fetch the repo from the source repository (tried both scenarios above)
"com.orgname.reponame": "git+ssh://git@gitlab.com/orgname/level1/level2/reponame.git",
HTTPS:
"com.orgname.reponame": "https://gitlab.com/orgname/level1/level2/reponame.git",```
While the HTTPS reference works well on Unity Editor (with windows credential manager), SSH fails to work both in Unity Editor (development machines) and in command-line builds (both development machines and build machine described above).
Error message is:
```[Package Manager] Done resolving packages in 2.07s seconds
An error occurred while resolving packages:
Project has invalid dependencies:
com.orgname.reponame: Error when executing git command. remote:
remote: ========================================================================
remote:
remote: ERROR: The project you were looking for could not be found or you don't have permission to view it.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
A re-import of the project may be required to fix the issue or a manual modification of C:/a/1/s/src-unity/kit2/Packages/manifest.json file.
Exiting without the bug reporter. Application will terminate with return code 1
Build finished!```
So, after making as sure as we can that configuration is as intended, we ran out of ideas on how to get UPM to fetch git+ssh packages.
Your setup looks fine. The error message seems to indicate that the SSH key sent by Git to authenticate itself with the SSH server works (otherwise you would get a message like “Permission denied (publickey)”), but the key itself isn’t associated with a user account on the Gitlab server that has access to the repo. This could happen for instance if the wrong Git is used, should you have multiple ones installed, as they don’t necessarily look up the SSH credentials in the same folder.
One thing you can do to diagnose this is to replace GIT_SSH with GIT_SSH_COMMAND, which is more flexible and lets you specify a command-line rather than just an executable. You can use it with e.g. “ -vvv” so that in the upm.log, you should see SSH verbose logs, which could confirm which key is used, if there are any problems while connecting (doesn’t seem to be the case here but who knows?), etc. Hopefully that can put you on the right track to solve this problem.
Thanks! This is what we were looking for - how to get the verbose debug from ssh. Once we did it, we saw that git was trying to login using someuser@ instead of git@.
Please bear in mind that path probably has to be quoted as it usually includes spaces via “Program Files”. As @maximweb pointed out, GIT_SSH_COMMAND is interpreted.