You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitHub提交正常但突发Permission denied(publickey)权限问题求助

Fixing GitHub SSH Permission Denied (publickey) After Working Previously

Hey there, let's work through this SSH permission denied issue since you've already verified your key's fingerprint matches on GitHub. Even though your key looks correct, there are a few common gotchas that can cause this sudden failure:

  • Check if your SSH agent is running and has your key loaded
    Sometimes the SSH agent stops running, or your key isn't added to it. First, list loaded keys with:

    ssh-add -l
    

    If you don't see your github_rsa key's fingerprint, add it with:

    ssh-add ~/.ssh/github_rsa
    

    If you get an error like "Could not open a connection to your authentication agent", start the agent first:

    eval "$(ssh-agent -s)"
    

    Then re-run the ssh-add command.

  • Verify your SSH config file is set up for GitHub
    Make sure your ~/.ssh/config file explicitly tells SSH to use your GitHub key for connections to github.com. Create or edit the file to include:

    Host github.com
      HostName github.com
      User git
      IdentityFile ~/.ssh/github_rsa
    

    Also, fix the file permissions to avoid SSH rejecting them:

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/config
    
  • Test your SSH connection to GitHub
    Run this command to debug the connection directly:

    ssh -T git@github.com
    

    A successful connection will say something like "Hi [your-username]! You've successfully authenticated, but GitHub does not provide shell access." If you still get permission denied, double-check that your GitHub account has access to the repository (especially if it's a private repo) and that no recent changes were made to your account's SSH key settings.

  • Confirm your git remote uses the SSH URL
    It's possible your repo's remote was switched to HTTPS accidentally. Check with:

    git remote -v
    

    If you see an HTTPS URL (like https://github.com/username/repo.git), switch it to SSH:

    git remote set-url origin git@github.com:your-username/your-repo.git
    
  • Rule out conflicting SSH keys
    If you have multiple SSH keys on your system, SSH might be trying to use the wrong one for GitHub. The config file step above fixes this by forcing GitHub connections to use your specific github_rsa key.

内容的提问来源于stack exchange,提问作者Pablo Pazos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:51:51