Permission Denied

Should the sudo command or elevated privileges be used with Git?

You should non be using the sudo command or elevated privileges, such equally administrator permissions, with Git. If yous take a very good reason you must utilise sudo, so ensure you are using it with every control (it's probably simply better to use su to get a shell as root at that point). If you generate SSH keys without sudo and so endeavor to utilize a command like sudo git push, you lot won't exist using the aforementioned keys that you generated.

Cheque that y'all are connecting to the correct server

Typing is difficult, we all know it. Pay attention to what you type; yous won't be able to connect to "githib.com" or "guthub.com". In some cases, a corporate network may cause bug resolving the DNS record as well.

To brand certain you are connecting to the right domain, you can enter the post-obit command:

          $ ssh -vT git@github.com > OpenSSH_8.1p1, LibreSSL two.7.3 > debug1: Reading configuration data /Users/you/.ssh/config > debug1: Reading configuration data /etc/ssh/ssh_config > debug1: /etc/ssh/ssh_config line 47: Applying options for * > debug1: Connecting to github.com port 22.        

The connection should be made on port 22, unless you're overriding settings to utilize SSH over HTTPS.

Always apply the "git" user

All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:

          $ ssh -T            GITHUB-USERNAME@github.com > Permission denied (publickey).        

If your connectedness failed and y'all're using a remote URL with your GitHub username, you can change the remote URL to use the "git" user.

You should verify your connection by typing:

          $ ssh -T git@github.com > Hi            username! You've successfully authenticated...        

Brand sure you have a key that is existence used

  1. Open Concluding Final Git Bash.
  2. Verify that you take a private primal generated and loaded into SSH.
                    # start the ssh-agent in the background $ eval "$(ssh-agent -s)" > Agent pid 59566 $ ssh-add -l -E sha256 > 2048                  SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ                  /Users/USERNAME/.ssh/id_rsa (RSA)              

If yous take GitHub Desktop installed, you tin can utilize it to clone repositories and not deal with SSH keys.

  1. If you are using Git Bash, turn on ssh-agent:

                    # start the ssh-agent in the background $ eval "$(ssh-amanuensis -southward)" > Amanuensis pid 59566              

    If you are using some other concluding prompt, such as Git for Windows, turn on ssh-agent:

                    # showtime the ssh-agent in the background $ eval $(ssh-agent -southward) > Agent pid 59566              
  2. Verify that you take a private key generated and loaded into SSH.

                    $ ssh-add -l -East sha256 > 2048                  SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ                  /Users/USERNAME/.ssh/id_rsa (RSA)              
  1. Open Terminal Terminal Git Bash.
  2. Verify that yous have a private central generated and loaded into SSH.
                    $ ssh-add -l -E sha256 > 2048                  SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ                  /Users/USERNAME/.ssh/id_rsa (RSA)              

The ssh-add together control should print out a long cord of numbers and letters. If it does not print anything, you will need to generate a new SSH key and associate it with GitHub.

Tip: On most systems the default private keys (~/.ssh/id_rsa and ~/.ssh/identity) are automatically added to the SSH authentication agent. Yous shouldn't need to run ssh-add path/to/primal unless y'all override the file proper noun when you generate a key.

Getting more details

Yous tin besides bank check that the key is beingness used by trying to connect to git@github.com:

          $ ssh -vT git@github.com > ... > debug1: identity file /Users/you lot/.ssh/id_rsa type -1 > debug1: identity file /Users/you/.ssh/id_rsa-cert type -1 > debug1: identity file /Users/you/.ssh/id_dsa type -ane > debug1: identity file /Users/you/.ssh/id_dsa-cert type -one > ... > debug1: Authentications that can continue: publickey > debug1: Side by side hallmark method: publickey > debug1: Trying private primal: /Users/y'all/.ssh/id_rsa > debug1: Trying private central: /Users/you/.ssh/id_dsa > debug1: No more authentication methods to try. > Permission denied (publickey).        

In that case, we did not have any keys for SSH to use. The "-1" at the stop of the "identity file" lines means SSH couldn't find a file to utilize. Subsequently on, the "Trying private key" lines also indicate that no file was found. If a file existed, those lines would be "1" and "Offer public key", respectively:

          $ ssh -vT git@github.com > ... > debug1: identity file /Users/you/.ssh/id_rsa type 1 > ... > debug1: Authentications that can proceed: publickey > debug1: Next authentication method: publickey > debug1: Offer RSA public key: /Users/you lot/.ssh/id_rsa        

Verify the public fundamental is attached to your account

You must provide your public primal to GitHub to establish a secure connection.

  1. Open Terminal.

  2. Starting time SSH agent in the groundwork.

                    $ eval "$(ssh-agent -south)" > Amanuensis pid 59566              
  3. Discover and accept a notation of your public primal fingerprint.

                    $ ssh-add -50 -E sha256 > 2048                  SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ                  /Users/USERNAME/.ssh/id_rsa (RSA)              
  4. In the upper-right corner of any page, click your profile photo, then click Settings.

    Settings icon in the user bar

  5. In the "Access" department of the sidebar, click SSH and GPG keys.

  6. Compare the listing of SSH keys with the output from the ssh-add control. SSH key listing in GitHub

  1. Open the command line.

  2. Beginning SSH amanuensis in the background.

                    $ ssh-agent -south > Amanuensis pid 59566              
  3. Detect and take a annotation of your public key fingerprint.

                    $ ssh-add -fifty -E sha256 > 2048                  SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ                  /Users/USERNAME/.ssh/id_rsa (RSA)              
  4. In the upper-correct corner of whatsoever folio, click your profile photo, then click Settings.

    Settings icon in the user bar

  5. In the "Admission" section of the sidebar, click SSH and GPG keys.

  6. Compare the list of SSH keys with the output from the ssh-add command. SSH key listing in GitHub

  1. Open up Terminal.

  2. Kickoff SSH agent in the background.

                    $ eval "$(ssh-amanuensis -south)" > Agent pid 59566              
  3. Find and take a notation of your public fundamental fingerprint. If you're using OpenSSH 6.seven or older:

                    $ ssh-add -fifty > 2048                  a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d                  /Users/USERNAME/.ssh/id_rsa (RSA)              

    If you're using OpenSSH half-dozen.viii or newer:

                    $ ssh-add together -50 -E md5 > 2048                  MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d                  /Users/USERNAME/.ssh/id_rsa (RSA)              
  4. In the upper-right corner of whatsoever page, click your profile photo, then click Settings.

    Settings icon in the user bar

  5. In the "Access" section of the sidebar, click SSH and GPG keys.

  6. Compare the list of SSH keys with the output from the ssh-add command. SSH key listing in GitHub

If you don't see your public key in GitHub, yous'll demand to add together your SSH central to GitHub to acquaintance it with your computer.

Warning: If you meet an SSH key you lot're not familiar with on GitHub, delete it immediately and contact GitHub Support, for further assist. An unidentified public key may betoken a possible security concern. For more information, see "Reviewing your SSH keys."

chestersionerve.blogspot.com

Source: https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey

0 Response to "Permission Denied"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel