Getting permission denied (public key) on gitlab

前端 未结 30 2269
太阳男子
太阳男子 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:42

    I use ubuntu 18.04, and it was actually permission issue in my local machine. The issue was gone when I set read/write permission to my .git folder.

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

    make sure you are not running sudo git clone git@gitlab.com:project/somethiing.git, otherwise ssh will look in /root/.ssh instead of the key you uploaded ~/.ssh/id_rsa

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

    How to add SSH key to gitlab account in ubuntu?

    1. Open terminal in your project directory.
    2. Type ‘ssh-keygen -o -t rsa -b 4096 -C "your gitlab email" ’ and hit enter
    3. Type ‘vim /home/mnbtech/.ssh/id_rsa.pub’ and hit enter (or manually open your 'id_rsa.pub'from where you saved it)
    4. SSH key will appear. Copy those and

    5. Go to your gitlab account.

    6. Click profile image And click setting
    7. In left side select SSH-Keys
    8. Then paste those key Click add key

    SSH-Key will be added!

    (N.B if you have Generate Previews SSH Key and Getting permission denied (public key). You Delete Your Previews ssh key and Generate new one and add git user.name and email on your terminal )

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

    There is a very simple solution to this: instead of working with ssh - move to https. to do this: in your project folder you have a .git folder in there - you have a config file - open it in a text editor and change the line

    url =git@gitlab.com:yourname/yourproject.git

    to

    url = https://gitlab.com/yourname/yourproject.git

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

    Steps to be done, got same error but i fixed it. Gitlab wants ssh-rsa so below is the code to run ssh for rsa

    1. ssh-keygen -o -t rsa -b 4096 -C "name@gmail.com"

    name@gmail.com is your gitlab account email

    1. It will prompt you to enter so just hit Enter after the below code is prompt,

      Enter file in which to save the key (/home/yourDesktopName/.ssh/id_rsa):

    2. It will prompt again you to enter so just hit Enter after the below code is prompt,

      Enter passphrase (empty for no passphrase):

    3. It will prompt again for the last you to enter so just hit Enter after the below code is prompt,

      Enter same passphrase again:

    4. You will show your ssh-rsa generate.

    5. Login to your Gitlab account and Go to the right navbar you will get setting and in the left sidebar you will get ssh key. Enter in it.

    6. Look above the prompt asking you to enter, you will get the path of ssh-rsa.

    7. Go to your SSH folder and get the id_rsa.pub

    8. Open it and get the key and Copy Paste to the Gitlab and you are nearly to done.

    9. Check by: ssh -T git@gitlab.com

    10. You will get: Welcome to GitLab, @joy4!

    11. Done.

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

    When you have multiple git account and you want different ssh key

    You have to follow same step for generating the ssh key, but be sure you

    ssh-keygen -t ed25519 -C "your-email-id@gmail.com" 
    

    Enter the path you want to save(Ex: my-pc/Desktop/.ssh/ed25519)

    Add the public key to your gitlab (How to adding ssh key to gitlab)

    You have to new ssh identity using the below comand

    ssh-add ~/my-pc/Desktop/.ssh/ed25519
    
    0 讨论(0)
提交回复
热议问题