Fix "Permission denied (publickey)" error when pushing with Git
This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:
*nixbased command prompt (but not the default Windows Command Prompt!)
cd ~/.ssh. This will take you to the root directory for Git (Likely
.sshfolder, there should be these two files:
id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type
lsto see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named
id_rsa.pubin order for Git, GitHub, and BitBucket to recognize them by default.
ssh-keygen -t rsa -C "firstname.lastname@example.org". This will create both
id_rsa.pubin your favorite text editor (you can do this via Windows Explorer or the OSX Finder if you like, tpying
open .will open the folder).
id_rsa.puband paste it into GitHub and/or BitBucket under the Account Settings > SSH Keys. NOTE: I like to give the SSH key a descriptive name, usually with the name of the workstation I'm on along with the date.
git pushagain and see if it works. It should!