Ssh Permission Denied
Should the sudo
control or elevated privileges be used with Git?
You should non be using the sudo
command or elevated privileges, such as administrator permissions, with Git. If you lot take a very good reason you lot must apply sudo
, then ensure you are using information technology with every command (it's probably only better to employ su
to go a beat as root at that point). If you lot generate SSH keys without sudo
so endeavour to use a command like sudo git push
, you won't exist using the aforementioned keys that you generated.
Check that yous are connecting to the right server
Typing is hard, we all know it. Pay attention to what you type; you lot won't be able to connect to "githib.com" or "guthub.com". In some cases, a corporate network may crusade issues resolving the DNS tape as well.
To make sure yous are connecting to the right domain, yous can enter the following command:
$ ssh -vT git@github.com > OpenSSH_8.1p1, LibreSSL ii.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 use SSH over HTTPS.
E'er employ the "git" user
All connections, including those for remote URLs, must exist made as the "git" user. If yous try to connect with your GitHub username, it will neglect:
$ ssh -T GITHUB-USERNAME@github.com > Permission denied (publickey).
If your connection failed and yous're using a remote URL with your GitHub username, you tin change the remote URL to use the "git" user.
You should verify your connection by typing:
$ ssh -T git@github.com > Hullo username! You've successfully authenticated...
Brand sure you have a fundamental that is being used
- Open Last Concluding Git Fustigate.
- Verify that y'all have a individual cardinal generated and loaded into SSH.
# get-go 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 accept GitHub Desktop installed, you can use information technology to clone repositories and not bargain with SSH keys.
-
If you are using Git Bash, turn on ssh-agent:
# commencement the ssh-agent in the groundwork $ eval "$(ssh-agent -s)" > Agent pid 59566
If y'all are using another terminal prompt, such as Git for Windows, turn on ssh-agent:
# first the ssh-agent in the background $ eval $(ssh-agent -south) > Agent pid 59566
-
Verify that you have a private key generated and loaded into SSH.
$ ssh-add together -l -Eastward sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
- Open Concluding Terminal Git Bash.
- Verify that y'all have a private key generated and loaded into SSH.
$ ssh-add -fifty -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
The ssh-add
command should print out a long string of numbers and letters. If it does not print anything, you lot volition need to generate a new SSH central and associate it with GitHub.
Tip: On most systems the default individual keys (~/.ssh/id_rsa
and ~/.ssh/identity
) are automatically added to the SSH authentication amanuensis. Yous shouldn't need to run ssh-add path/to/key
unless you override the file name when you lot generate a fundamental.
Getting more details
You lot can likewise cheque that the key is being used by trying to connect to git@github.com
:
$ ssh -vT git@github.com > ... > debug1: identity file /Users/you/.ssh/id_rsa blazon -1 > debug1: identity file /Users/you lot/.ssh/id_rsa-cert type -1 > debug1: identity file /Users/y'all/.ssh/id_dsa type -1 > debug1: identity file /Users/you/.ssh/id_dsa-cert type -1 > ... > debug1: Authentications that tin proceed: publickey > debug1: Next authentication method: publickey > debug1: Trying private primal: /Users/you lot/.ssh/id_rsa > debug1: Trying private central: /Users/yous/.ssh/id_dsa > debug1: No more authentication methods to try. > Permission denied (publickey).
In that example, we did not have any keys for SSH to use. The "-1" at the finish of the "identity file" lines means SSH couldn't find a file to use. Later on, the "Trying private fundamental" lines also indicate that no file was plant. If a file existed, those lines would be "ane" and "Offering public central", respectively:
$ ssh -vT git@github.com > ... > debug1: identity file /Users/yous/.ssh/id_rsa type ane > ... > debug1: Authentications that can continue: publickey > debug1: Side by side authentication method: publickey > debug1: Offering RSA public central: /Users/you/.ssh/id_rsa
Verify the public primal is attached to your account
You must provide your public fundamental to GitHub to establish a secure connection.
-
Open Terminal.
-
Start SSH amanuensis in the groundwork.
$ eval "$(ssh-agent -southward)" > Agent pid 59566
-
Find and take a note of your public key fingerprint.
$ ssh-add -50 -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
-
In the upper-correct corner of any 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 together
command.
-
Open the command line.
-
Start SSH agent in the background.
$ ssh-agent -south > Agent pid 59566
-
Find and have a annotation of your public central fingerprint.
$ ssh-add -l -E sha256 > 2048 SHA256:274ffWxgaxq/tSINAykStUL7XWyRNcRTlcST1Ei7gBQ /Users/USERNAME/.ssh/id_rsa (RSA)
-
In the upper-correct corner of any page, click your profile photo, then click Settings.
-
In the "Access" section of the sidebar, click SSH and GPG keys.
-
Compare the listing of SSH keys with the output from the
ssh-add
control.
-
Open Concluding.
-
Showtime SSH agent in the background.
$ eval "$(ssh-amanuensis -south)" > Agent pid 59566
-
Find and accept a note of your public key fingerprint. If you're using OpenSSH 6.vii 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 lot're using OpenSSH 6.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 whatsoever folio, click your profile photograph, so click Settings.
-
In the "Access" section of the sidebar, click SSH and GPG keys.
-
Compare the listing of SSH keys with the output from the
ssh-add
command.
If you don't see your public cardinal in GitHub, you'll need to add your SSH key to GitHub to associate it with your calculator.
Warning: If you see an SSH key yous're not familiar with on GitHub, delete information technology immediately and contact GitHub Support, for farther assist. An unidentified public key may indicate a possible security business. For more than information, encounter "Reviewing your SSH keys."
arnoldshoubless60.blogspot.com
Source: https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey
0 Response to "Ssh Permission Denied"
Post a Comment