Getting permission denied (public key) on gitlab

前端 未结 30 2268
太阳男子
太阳男子 2020-12-02 04:27

My problem is that I can\'t push or fetch from GitLab. However, I can clone (via HTTP or via SSH). I get this error when I try to push :

Permission de

相关标签:
30条回答
  • 2020-12-02 04:47

    I solved git@gitlab.com: Permission denied (publickey) issue using following instructions

    1. RUN cat ~/.ssh/id_rsa.pub
    2. Copy id_rsa.pub (public key) to your getlab `Setting -> SSH Keys
    3. RUN cat ~/.ssh/id_rsa
    4. Copy id_rsa (private key) to `Code_repo->git_auth->id_rsa

    NOTE: Take care of the machine user if you are using root user in your DockerFile or anywhere else then use sudo su before running the above commands to get root user public and private keys.

    0 讨论(0)
  • 2020-12-02 04:48

    I found this after searching a lot. It will work perfectly fine for me.

    1. Go to "Git Bash" just like cmd. Right click and "Run as Administrator".
    2. Type ssh-keygen
    3. Press enter.
    4. It will ask you to save the key to the specific directory.
    5. Press enter. It will prompt you to type password or enter without password.
    6. The public key will be created to the specific directory.
    7. Now go to the directory and open .ssh folder.
    8. You'll see a file id_rsa.pub. Open it on notepad. Copy all text from it.
    9. Go to https://gitlab.com/profile/keys .
    10. Paste here in the "key" textfield.
    11. Now click on the "Title" below. It will automatically get filled.
    12. Then click "Add key".

    Now give it a shot and it will work for sure.

    0 讨论(0)
  • 2020-12-02 04:48

    I found the solution in gitlab help.

    To create a new SSH key pair: 
     1. Open a terminal on Linux or macOS, or Git Bash / WSL on Windows.
     2. Generate a new ED25519 SSH key pair: ssh-keygen -t ed25519 -C "email@example.com"
     2.1 Or, if you want to use RSA: ssh-keygen -o -t rsa -b 4096 -C "email@example.com"
     3. Next, you will be prompted to input a file path to save your SSH key pair to... use the suggested path by pressing Enter
     4. Once the path is decided, you will be prompted to input a password to secure your new SSH key pair. It's a best practice to use a password, but it's not required and you can skip creating it by pressing Enter twice.
     5. Copy your public SSH key to the clipboard by using one of the commands below depending on your Operating System:
            macOS:        pbcopy < ~/.ssh/id_ed25519.pub
            WSL / GNU/Linux (requires the xclip package):      xclip -sel clip < ~/.ssh/id_ed25519.pub
            Git Bash on Windows:      cat ~/.ssh/id_ed25519.pub | clip
     6. Navigating to SSH Keys and pasting your public key in the Key field
     7. Click the Add key button
    

    I hope it can help some of you!

    0 讨论(0)
  • 2020-12-02 04:49

    In my case it did not work in the WSL (Windows Subsystem for Linux).

    When I start the WSL, I must

    • start ssh-agent_ eval $(ssh-agent -s)
    • add the key to the ssh-agent: ssh-add ~/.ssh/id_rsa
    • if prompted, enter the password

    Now the connection works.
    We can test this with ssh -T git@github.com

    notes:

    • weasel-pageant allows us to reuse the ssh keys that are loaded in PuTTY pageant inside the WSL
    • detailed explanation: Git via SSH from Windows returns Permission Denied
    0 讨论(0)
  • 2020-12-02 04:49

    I solved like this..

    Generated a key for Windows using this command:

    ssh-keygen -t rsa -C "your.email@example.com" -b 4096
    

    but the problem was that after running this command, it popped a line: "Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa): " Here, I was giving only file name because of which my key was getting saved in my pwd and not in the given location. When I did "git clone ", it was assuming the key to be at "/c/Users/xxx/.ssh/id_rsa" location but it was not found, hence it was throwing error.

    At the time of key generation 2 files were generated say "file1" & "file1.pub". I renamed both these files as

    file1 -> id_rsa 
    

    and

    file1.pub -> id_rsa.pub
    

    and placed both in the location "/c/Users/xxx/.ssh/"

    0 讨论(0)
  • 2020-12-02 04:49

    Please use git config credential.helper store if your site is using TLS/SSL. Hope this works

    0 讨论(0)
提交回复
热议问题