Trouble pushing files to github

Hello,
I’m working on the full-stack engineer path (25% complete) and I’m now going to use GitHub to work on an off-platform project. However, I’m unable to get GitHub to communicate well with my computer. I did everything in this video four times, but keep getting error messages.

When I type:
git push -u origin main

I get the following response:

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.

Can anyone please help me solve this?
Thank you!!!
Sandy

Hi @7982544049. There are a couple of problems that could be causing this. Let’s check step by step.

Step 1. Check if you have more than one SSH key
First, please open up your terminal and list all your existing keys (do not post them, we do NOT need to see them) using this command ls ~/.ssh/id_ed25519.pub, replacing appropriately if you initially named your key differently. Use cat to display contents of public key that should be working.

Step 2. Login to github.com, navigate to settings, and view your current SSH keys. Make sure the public key matches. If you see any key that doesn’t belong, delete it.

Step 3. Perform SSH test following this article from GitHub: Testing your SSH connection - GitHub Docs.

IMPT: Step 1 will tell you if you are using the right key “name” to communicate with GitHub. Step 2 will tell you if the contents of your public key match what you have uploaded to GitHub. Step 3 will check for connectivity and if you have a password protecting your key, will prompt for that. If you get an error in entering your password, you have found a culprit.

Step 4. Other Troubleshooting:
Other culprits could include that you did not configure your username or email to properly match in .gitconfig. You can set those by following steps here: Setting Up Git | The Odin Project. Finally, you may have initially and accidentally rejected the remote host when establishing your connection.

Let me know if that helps. Additionally, please check your Git version and let us know so we can continue to help.

1 Like

Thank you so much for these instructions, Milo. My apologies for the delayed reply.

I opened gitbash and typed in
ls ~/.ssh/id_ed25519.pub

and got this response:
ls: cannot access ‘/c/Users/AB/.ssh/id_ed25519.pub’: No such file or directory

Did I misunderstand your instructions?
Sandy

@7982544049 My apologies, I assumed here you were using Bash on a Linux distro, but understand now that you are working from Windows. I do not have much familiarity with git on Windows, but your keys should still be visible (if you have keys) using the steps from GitHub in the previous link. Git and SSH keys are two different things, SSH is a protocol for connecting and pushing to your remote, in this case GitHub. Git, is the version control system–you have your repo locally, and SSH allows you to authenticate to push to the remote. Just to clarify those, so the article will make more sense. I am sorry my answer before wasn’t much help. Let me link the docs for Git and GitHub below:

Important: It’s not a big risk, but you might want to provide just the relative path from the output and instead of your path to your directory… as in ~/.ssh/ just for privacy sake, and of course never post your private key contents.

Kindly let me know if the troubleshooting guide helped. Maybe there are others here who are working from Windows and can provide insight.

Cheers! Milo