Ssh Permission Denied
Should the sudo
command or elevated privileges be used with Git?
You should not be using the sudo
command or elevated privileges, such equally administrator permissions, with Git. If you have a very expert reason you must apply sudo
, then ensure yous are using it with every control (it'due south probably just better to use su
to get a shell equally root at that bespeak). If you generate SSH keys without sudo
and then attempt to use a command like sudo git push
, you lot won't be using the same keys that you generated.
Check that you are connecting to the correct server
Typing is difficult, we all know it. Pay attention to what you type; y'all won't exist able to connect to "githib.com" or "guthub.com". In some cases, a corporate network may crusade problems resolving the DNS tape as well.
To make sure yous are connecting to the right domain, you lot can enter the post-obit command:
$ ssh -vT git@github.com > OpenSSH_8.1p1, LibreSSL 2.7.3 > debug1: Reading configuration information /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 use SSH over HTTPS.
Always use 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 volition fail:
$ ssh -T GITHUB-USERNAME@github.com > Permission denied (publickey).
If your connectedness failed and you're using a remote URL with your GitHub username, y'all can change the remote URL to use the "git" user.
You should verify your connexion by typing:
$ ssh -T git@github.com > Hi username! You've successfully authenticated...
Brand sure you have a key that is existence used
- Open Final Terminal Git Bash.
- Verify that you have a private key generated and loaded into SSH.
# commencement the ssh-agent in the background $ eval "$(ssh-agent -s)" > Agent pid 59566 $ ssh-add -fifty -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
If you have GitHub Desktop installed, you tin can employ it to clone repositories and not deal with SSH keys.
-
If you are using Git Bash, plow on ssh-agent:
# showtime the ssh-amanuensis in the background $ eval "$(ssh-agent -s)" > Agent pid 59566
If you are using another concluding prompt, such equally Git for Windows, plough on ssh-amanuensis:
# start the ssh-amanuensis in the background $ eval $(ssh-agent -s) > Agent pid 59566
-
Verify that y'all have a private primal generated and loaded into SSH.
$ ssh-add together -50 -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
- Open Terminal Terminal Git Bash.
- Verify that y'all take a private key generated and loaded into SSH.
$ ssh-add -l -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
The ssh-add
command should impress out a long cord of numbers and letters. If it does not impress annihilation, you lot will need to generate a new SSH key and acquaintance it with GitHub.
Tip: On most systems the default individual 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/key
unless you lot override the file proper noun when you generate a key.
Getting more details
You can also cheque that the key is being used by trying to connect to git@github.com
:
$ ssh -vT git@github.com > ... > debug1: identity file /Users/yous/.ssh/id_rsa type -1 > debug1: identity file /Users/yous/.ssh/id_rsa-cert type -ane > debug1: identity file /Users/you lot/.ssh/id_dsa blazon -1 > debug1: identity file /Users/you/.ssh/id_dsa-cert type -ane > ... > debug1: Authentications that can keep: publickey > debug1: Side by side authentication method: publickey > debug1: Trying private fundamental: /Users/y'all/.ssh/id_rsa > debug1: Trying individual key: /Users/you/.ssh/id_dsa > debug1: No more authentication methods to try. > Permission denied (publickey).
In that example, nosotros did not accept whatever keys for SSH to use. The "-1" at the end of the "identity file" lines means SSH couldn't find a file to use. Subsequently on, the "Trying private fundamental" lines too bespeak that no file was found. If a file existed, those lines would be "1" and "Offering public key", respectively:
$ ssh -vT git@github.com > ... > debug1: identity file /Users/you/.ssh/id_rsa type 1 > ... > debug1: Authentications that tin keep: publickey > debug1: Next hallmark method: publickey > debug1: Offering RSA public fundamental: /Users/yous/.ssh/id_rsa
Verify the public central is attached to your account
You must provide your public primal to GitHub to establish a secure connexion.
-
Open up Terminal.
-
Offset SSH agent in the background.
$ eval "$(ssh-agent -s)" > Agent pid 59566
-
Observe and take a annotation of your public cardinal fingerprint.
$ ssh-add -l -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
-
In the upper-right corner of any page, click your contour photo, then click Settings.
-
In the "Admission" department of the sidebar, click SSH and GPG keys.
-
Compare the list of SSH keys with the output from the
ssh-add
command.
-
Open the control line.
-
Beginning SSH agent in the background.
$ ssh-agent -s > Agent pid 59566
-
Notice and accept a note of your public key fingerprint.
$ ssh-add -l -Eastward sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
-
In the upper-right corner of whatsoever folio, click your profile photo, then click Settings.
-
In the "Access" section of the sidebar, click SSH and GPG keys.
-
Compare the list of SSH keys with the output from the
ssh-add
command.
-
Open up Terminal.
-
Start SSH agent in the background.
$ eval "$(ssh-agent -southward)" > Amanuensis pid 59566
-
Find and accept a note of your public cardinal fingerprint. If you're using OpenSSH vi.7 or older:
$ ssh-add -l > 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 lot're using OpenSSH six.8 or newer:
$ ssh-add -l -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)
-
In the upper-right corner of any page, click your profile photograph, then click Settings.
-
In the "Access" department of the sidebar, click SSH and GPG keys.
-
Compare the list of SSH keys with the output from the
ssh-add
command.
If you lot don't see your public key in GitHub, you'll demand to add your SSH primal to GitHub to associate it with your calculator.
Alarm: If you see an SSH key you're not familiar with on GitHub, delete information technology immediately and contact GitHub Back up, for farther help. An unidentified public cardinal may betoken a possible security concern. For more than information, see "Reviewing your SSH keys."
Source: https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey
0 Response to "Ssh Permission Denied"
Post a Comment