Skip to content

Instantly share code, notes, and snippets.

@7aman
Forked from adamjohnson/publickey-git-error.markdown
Last active December 16, 2020 09:07
Show Gist options
  • Select an option

  • Save 7aman/3e62da99c8d7037ff6b395bec187f429 to your computer and use it in GitHub Desktop.

Select an option

Save 7aman/3e62da99c8d7037ff6b395bec187f429 to your computer and use it in GitHub Desktop.

Revisions

  1. 7aman revised this gist Dec 16, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions publickey-git-error.markdown
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,10 @@ This means, on your local machine, you haven't made any SSH keys. Not to worry.
    3. Within the `.ssh` folder, there should be these two files: `id_rsa` and `id_rsa.pub`. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type `ls` to 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` and `id_rsa.pub` in order for Git, GitHub, and BitBucket to recognize them by default.
    4. To create the SSH keys, type `ssh-keygen -t rsa -C "[email protected]"`. This will create both `id_rsa` and `id_rsa.pub` files.
    5. Now, go and open `id_rsa.pub` in your favorite text editor (you can do this via Windows Explorer or the OSX Finder if you like, tpying `open .` will open the folder).
    6. Copy the contents--exactly as it appears, with no extra spaces or lines--of `id_rsa.pub` and paste it into GitHub and/or BitBucket under the Account Settings > SSH Keys.
    6. Copy the contents--exactly as it appears, with no extra spaces or lines--of `id_rsa.pub` and paste it into GitHub, BitBucket or gitlab 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.
    7. Now that you've added your public key to Github and/or BitBucket, try to `git push` again and see if it works. It should!
    7. Now that you've added your public key to Github, BitBucket or gitlab.
    try `ssh -T [email protected]` for example to see if it is working.
    Now you can try to `git push` again. It should!

    More help available from [GitHub on creating SSH Keys](https://help.github.com/articles/generating-ssh-keys) and [BitBucket Help](https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues).
  2. @adamjohnson adamjohnson revised this gist May 31, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions publickey-git-error.markdown
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    ### "Help, I keep getting a 'Permission Denied (publickey)' error when I push!"
    This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

    1. Open git bash (Use the Windows search. To find it, type "git bash"). __Pro Tip:__ You can use any `*nix` based command prompt (but *not* the Windows Command Prompt!)
    1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. __Pro Tip:__ You can use any `*nix` based command prompt (but *not* the default Windows Command Prompt!)
    2. Type `cd ~/.ssh`. This will take you to the root directory for Git (Likely `C:\Users\[YOUR-USER-NAME]\.ssh\` on Windows)
    3. Within the `.ssh` folder, there should be these two files: `id_rsa` and `id_rsa.pub`. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type `ls` to 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` and `id_rsa.pub` in order for Git, GitHub, and BitBucket to recognize them by default.
    4. To create the SSH keys, type `ssh-keygen -t rsa -C "[email protected]"`. This will create both `id_rsa` and `id_rsa.pub` files.
    5. Now, go and open `id_rsa.pub` in your favorite text editor (you can do this via Windows Explorer or the OSX Finder if you like).
    5. Now, go and open `id_rsa.pub` in your favorite text editor (you can do this via Windows Explorer or the OSX Finder if you like, tpying `open .` will open the folder).
    6. Copy the contents--exactly as it appears, with no extra spaces or lines--of `id_rsa.pub` and 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.
    7. Now that you've added your public key to Github and/or BitBucket, try to `git push` again and see if it works. It should!

    More help available from [GitHub on creating SSH Keys](https://help.github.com/articles/generating-ssh-keys) and [BitBucket Help](https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues).
    More help available from [GitHub on creating SSH Keys](https://help.github.com/articles/generating-ssh-keys) and [BitBucket Help](https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues).
  3. @adamjohnson adamjohnson created this gist May 31, 2013.
    13 changes: 13 additions & 0 deletions publickey-git-error.markdown
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ### "Help, I keep getting a 'Permission Denied (publickey)' error when I push!"
    This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

    1. Open git bash (Use the Windows search. To find it, type "git bash"). __Pro Tip:__ You can use any `*nix` based command prompt (but *not* the Windows Command Prompt!)
    2. Type `cd ~/.ssh`. This will take you to the root directory for Git (Likely `C:\Users\[YOUR-USER-NAME]\.ssh\` on Windows)
    3. Within the `.ssh` folder, there should be these two files: `id_rsa` and `id_rsa.pub`. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type `ls` to 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` and `id_rsa.pub` in order for Git, GitHub, and BitBucket to recognize them by default.
    4. To create the SSH keys, type `ssh-keygen -t rsa -C "[email protected]"`. This will create both `id_rsa` and `id_rsa.pub` files.
    5. Now, go and open `id_rsa.pub` in your favorite text editor (you can do this via Windows Explorer or the OSX Finder if you like).
    6. Copy the contents--exactly as it appears, with no extra spaces or lines--of `id_rsa.pub` and 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.
    7. Now that you've added your public key to Github and/or BitBucket, try to `git push` again and see if it works. It should!

    More help available from [GitHub on creating SSH Keys](https://help.github.com/articles/generating-ssh-keys) and [BitBucket Help](https://confluence.atlassian.com/display/BITBUCKET/Troubleshooting+SSH+Issues).