Editing
Troubleshooting of GIT
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== SSH Authentication Failed: Permission denied (publickey) === '''Error Message''' After keyin the command <pre>git clone git@github.com:your-org/your-repo.git /opt/your-app</pre>, met the error message <pre> Cloning into '/opt/your-app'... git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. </pre> '''Cause''' This error occurs when Git cannot authenticate with GitHub over SSH. This typically means the SSH key on your machine is either missing, not registered with your GitHub account, or not being picked up by the SSH agent. '''Solutions''' '''Option 1 — Configure your SSH config file''' Add an entry to `~/.ssh/config` so Git automatically uses the correct key: <pre> Host github.com HostName github.com User git IdentityFile /path/to/.ssh/your_key_name </pre> '''Option 2 — Pass the SSH key inline''' 1. Before running `git clone`, test whether the specified SSH key can successfully authenticate with GitHub: <pre> ssh -T -i /path/to/.ssh/your_key_name git@github.com </pre> If the key is configured correctly, you should see: <pre> Hi your-org/your-app! You've successfully authenticated, but GitHub does not provide shell access. </pre> `successfully authenticated` confirms the key is correctly linked to your GitHub account and you're good to proceed with `git clone`. The message `GitHub does not provide shell access` is expected — SSH is used for Git operations only, not for interactive shell login. 2. Override the SSH command directly when cloning: <pre> sudo GIT_SSH_COMMAND='ssh -i /path/to/.ssh/your_key_name -o IdentitiesOnly=yes' \ git clone git@github.com:your-org/your-repo.git /opt/your-app </pre> {{exclaim}} Notice: `-o IdentitiesOnly=yes` prevents SSH from trying other keys loaded in the agent, which can cause unexpected auth failures.
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information