添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi, I’m using Visual Code Studio on mac. I don’t know why, but I now get an error Git: [email protected] : Permission denied (publickey). when I try to push. I went through the Generating a new SSH key pair section on this page again, generated a new ssh key. I added it to my gitlab. I just don’t know what my next step is supposed to be or how I can check if everything is set up all right. FYI, I really am a newbie!

Thanks for the help!

Can you please share the exact steps you did, including the location of the generated ssh key pair? Also, which public key did you add to your gitlab.com profile?

Cheers,
Michael

  • Opened terminal
  • ssh-keygen -t ed25519 -C "[email protected]"
  • Pressed enter to use the default path.
  • Overwrited the current one y
  • Entered a passphrase (twice for verification)
  • From there, I

  • Entered pbcopy < ~/.ssh/id_ed25519.pub
  • Pasted the key in GitLab settings, starting with ssh-ed25519 and ending with [email protected]
  • Tested the setting with ssh -T [email protected]
  • Had the answer Welcome to GitLab, @JolinM!

    Did I forget something?

    thanks for sharing. I just wanted to make sure that all steps are taken and verified. This is a common source for errors.

    Maybe VSCode caches the SSH key, e.g. did you close and restart the app once?

    Cheers,
    Michael

    Hi again, I deleted my whole ~/.ssh folder and did all the again. Tried closing/reopening the app. I also tried while using Github Desktop, but it doesn’t work. :pensive:

    Here’s Github Desktop error message

    No idea unfortunately. I have stopped using SSH a while ago and am only using https auth tokens stored in my security key chain. The same should work with VS Code e.g. with adding the git clone https… command being asked for the credentials just once.

    Cheers,
    Michael

  • Personal auth token: https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
  • git clone https://server/group/repo.git - insert username and auth token string
  • Step 2 can happen in VS Code but I suggest to do it on the command line in your desired project location.

    Cheers,
    Michael

    It’s most likely becuase your SSH key wasn’t “unlocked”.

    On Mac after creating an SSH key you can add it to the keychain with:

    ssh-add -K ~/.ssh/[your-private-key]
    

    And in ~/.ssh/config you add:

    Host *
      UseKeychain yes
      AddKeysToAgent yes
      IdentityFile ~/.ssh/[your-private-key]
    

    So it knows where to look, and this will also make it so you don’t need to enter the passphrase each time, and thus VSCode is allowed to use they key, cause it’s unlocked not just when you’re pushing through CLI.

    ssh-add -K ~/.ssh/id_rsa

    I get the answer:

    Could not open a connection to your authentication agent.

    Can you help me with that?

    Cheers Shushu

    That’s most likely because your ssh-agent isn’t running.
    What are you using as a CLI?
    WSL, GitBash, Powershell?

    This article has a lot of different ways of enabling your ssh-agent depending on your terminal prompt.

    stackoverflow.com

    To enable SSH Agent automatically on Windows, start a local Administrator PowerShell and run the following commands:

    Yes,i am using Git Bash. It´s true vsCode can´t connect to agent… I tested it in the vsCode terminal by using

    ssd-add -l.

    I tryed to setup the SSH Agent by this tutorial: https://code.visualstudio.com/docs/remote/troubleshooting#_fixing-ssh-file-permission-errors

    It doen´t work because i dont have the admine rights.

    Do i have ony other idears?

    can´t download keys without provider

    i also open ssh-agent.cmd in my Git folder and entered my passphrase. It didn´t help.

    on this point i stuck now… :confused: