Search This Blog

Saturday, January 6, 2018

Ubuntu -Resolving gitlab Permission denied (publickey) on push

    1) Once you created gitlab account ,create a repository say "abc" on gitlab, with "code_dir" as folder to push to gitlab
    cd code_dir
    git init
    git remote add origin git@gitlab.com:your.name/abc.git
    git add .
    git commit -m "Initial commit"
    git push -u origin master

      at time of final push i got greeted with "gitlab Permission denied (publickey)" error,after to resolve it we need to create public-private key that identfies our machine & add it to gitab
      inside settings ,ssh key section.

    2) on terminal run
     ssh-keygen
     output:
        Generating public/private rsa key pair.
        Enter file in which to save the key (/home/sangram/.ssh/id_rsa):
        Enter passphrase (empty for no passphrase):
        Enter same passphrase again:
        Your identification has been saved in /home/username/.ssh/id_rsa.
        Your public key has been saved in /home/username/.ssh/id_rsa.pub.
        The key fingerprint is:
        SHA256:xwoAYiFpCTSM9QjvNfPfkh/NQAKhktRQ2zh6+tYo1u4 sangram@sangram-HP-Laptop-15-bs0xx
        The key's randomart image is:
        +---[RSA 2048]----+
        |XBB+. o.         |
        |=O.=.= .         |
        |. = @ . . .      |
        | . + *   +       |
        |  o . o S +      |
        |   o   o = +     |
        |  .. o  = o o    |
        |  o.+ .  o .     |
        | . =E     .      |
        +----[SHA256]-----+

    2) Cat /home/username/.ssh/id_rsa.pub
           copy all output to clipboard

    3) login to gitlab & visit
        settings-->SSH Keys
    in textbox for key on left paste key text & hit save.
    4) Now attempt push
    git push -u origin master

No comments:

Post a Comment