I'm working on a project in a private repository on https://www.bitbucket.com.
I'm coding it locally, then staging, commiting and pushing the update via BitBucket's / Atlassian's Windows Git client, Sourcetree.
After that, I'm pulling the files from a remote shared server, which requires SSH authentication.
I've tried the following in order to connect the git repo with the BitBucket account:
.ppk
(PuTTY Private Key) to Pageant using my passphraseC:/Project
.git init
to initialize the repository.git push -u origin --all
in order to push the repo from my computer to BitBucket.Permission denied (publickey).
ssh -Tv [email protected]
- Still, Permission denied
.I'm trying to figure out what exactly went wrong - did Sourcetee find my SSH key at all? Is the key not loaded in some specific place, causing this behavior?
Note: I have loaded the public key in my profile on BitBucket.
From Sourcetree, open the PuTTY Key Generator dialog by going to Tools > Create or Import SSH Keys. Click Load, navigate to your SSH folder, and click the private key. Make sure you're looking at All files if you don't see your private key. Enter your passphrase for the SSH key and click OK.
Add the public key to your repository From Bitbucket, go to the repository and click Repository settings. Click Access keys from the left menu. Press Add key. From the Add SSH key dialog, enter a Label and paste the public key from the clipboard.
To whom may have the same issue on Mac with new Sierra. Solution would be to add private key to SSH agent via:
ssh-add -K ~/.ssh/id_rsa
It looks like that identity[id_rsa] doesn't persist by SSH agent.
Note this is not a permanent solution .. You would need to do that each time you clone a new repository.At least then no need to provide private key for each push to remote.
-------- Update 28.Sep.2017 --------
Permanent solution ( On Sierra):
Steps:
1- Be sure that you have a running ssh-agent in background before doing anything.
To check if ssh-agent is running by:
pgrep 'ssh-agent'
That command returns PID (ProcessID) of that process if it's running. If you see a value.. Go to Step#2. if not, so you need to run that agent in background by:
eval "$(ssh-agent -s)"
2- Edit ~/.ssh/config
(Create if it doesn't exist as su
):
Host * AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_rsa
3- Then add that key agent ( that would be once ):
ssh-add -K ~/.ssh/id_rsa
That's it.
Actually Step#2 is the crucial one. I just want to provide a complete guide.
I hope that may help you.'.
I needed to further modify these settings SourceTree:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With