Have been using VSCode with Gitlab for a long time, connecting to multiple projects within the same Gitlab account without problems. I have been using the Gitlab Workflow VSCode extension, and set up a PAT to work with that extension some time ago.
Recently I got a notification that the PAT was going to expire.
So I created a new PAT and installed it following the instructions given with the Extension, but now have lost all access to the Gitlab projects within my account. One factor is what path I should use when installing the new PAT - should it be to the parent account directory, or to each specific project separately: I only ever installed one PAT when I set up the system. Documentation is not clear about what needs to be done.
Can anyone give me any guidance on how to resolve this issue so that my projects can reconnect with my Gitlab account? Many thanks in advance for any help that can be provided for this!
Thanks for taking the time to be thorough in your request, it really helps!
Hi.
I opened up Gitlab website, logged into my account, clicked on my avatar and chose āPreferencesā, then clicked on the āAccess Tokensā option on LH menu, and then created a new personal access token with read_user and api permissions.
I donāt follow what you mean by the parent account directory. Can you share the project and group structure you are using, and the membership permissions? The personal access token is tied to your user which needs to have appropriate permissions into groups and projects.
(There is something which is called a project access token, that is something different, mainly used for automation)
Also, please share whether it is a self-managed GitLab instance, including the version, or GitLab.com SaaS.
Hi Michael.
Itās a gitlab hosted thing.
So the path to the account is https://gitlab.com/account
The path to a project is https://gitlab.com/account/project
There are multiple projects held within the account (so account/project_1, account/project_2 etc.)
VSCode is connecting to each project separately, but I have (as far as I am aware) only ever created one PAT to allow Gitlab Workflow extension to see / interact with the projects.
So I am not clear if I create a new PAT for https://gitlab.com/account or one each for https://gitlab.com/account_1 ā¦ etc.
Have tried doing both types, and neither have worked.
VSCode reports āGit: Host key verification failed.ā when I try to sync to one of the projects.
Terminal reports āHost key verification failed.
fatal: Could not read from remote repository.ā
So am baffledā¦
Thank you so much for taking an interest, I hope there is a way for me to understand enough to fix this!
In your home directory, thereās ~/.ssh/known_hosts which caches the host key from your GitLab server. Search for the hostname in there, and delete the line.
Try to sync again. If it doesnāt work, lookup the servers IP address in the file and delete the line too.
If it works, you can keep the git operations with SSH, or change the origin to https shown above.
Hi Michael
Thanks for the extra info. I tried to reset the ssh connection / host key but that simply moved the issue. Now Iām getting the report back on trying to sync with the Gitlab account Git: git@gitlab.com: Permission denied (publickey,keyboard-interactive).
This may be progress, or may not.
Any more thoughts?
Then try a fetch/sync again. It will ask for your username (use the username) and the password (use the PAT). Allow Git to store the credentials in your OSāes credential store.
If it helps, you can also delete the project locally, and clone it again with
Michael
Thanks again for your patience with this.
We finally go there, not 100% same as you suggested, so noting here in case useful to another:
edited the .git/config file for the problem projects as you suggested - it looks like it was already doing https syncing, but I replaced what was there with a simple https://ā¦ entry of the type you suggested
went to the VSCode pop up menu and selected āGitlab: Remove Your Gitlab Personal Access Tokenā and then selected a project (to remove that token from that project)
created a new PAT in Gitlab web interface
went to VSCode pop up menu and selected āGitlab: Set Gitlab Personal Access Tokenā and then entered the project URL on gitlab for the project and then pasted in the PAT
synced the project - went through no problems
repeat for other projectsā¦
Thank you very very much for helping me to this happy place - I simply would not have got this sorted neatly without your helpā¦ next option was blowing the git project folders locally and re-creating, which would have been a pain!
glad you could figure it out, even being a tough call I learned new things myself, and future users can benefit from your detailed comments. Maybe youād like to stick around here and help with your expertise and/or feedback? Together we can answer more questions, and ensure that there more happy GitLab users out there