The problem is that, when you clone the wiki's repository, the clone is done through HTTPS, since the link provided by Bitbucket uses HTTPS to access the repository. What you need is a way to access using SSH as the protocol, instead of HTTPS.
It is actually possible to access the wiki's Git repository through SSH, although Bitbucket does not provide the link to do that.
Thanks to a ticket on Bitbucket's issue tracking system, I found that you can access the wiki repository through SSH by using the same URI of the project's repository, but with /wiki
appended.
So, if your project's repository is under git@bitbucket.org:UserName/project-name.git
, the wiki repository can be accessed at git@bitbucket.org:UserName/project-name.git/wiki
, instead of using the HTTPS URI provided by Bitbucket.
This way, you can clone your wiki by running the command
git clone git@bitbucket.org:UserName/project-name.git/wiki
or, if you have already cloned the wiki repository using HTTPS, you can change the origin
remote to use SSH by running the command
git remote set-url origin git@bitbucket.org:UserName/project-name.git/wiki
I have already tried this, and it works perfectly! You will not be prompted for your password anymore, since Git is now using SSH with your SSH key to log into the server.
ssh-agent
is the piece that you want to get working, as it does exactly what you're asking about. The agent runs as a daemon, and when you "add" a private key to it, it remembers that key and automatically provides it to the remote sshd
during the initial connection. (ssh-add
is simply the command you run to manually add a private key to ssh-agent
).
In OS X, as of Leopard, you shouldn't ever have to run ssh-agent
or ssh-add
manually. It should "just happen" when you attempt to connect to a server. Once per key, it will prompt you with a UI password dialog, which (among other things) will allow you to automatically add the key to the ssh-agent
so you never get prompted again.
This is handled by having a launchd
configuration that listens for connections on the $SSH_AUTH_SOCK
socket, and automatically launches ssh-agent
when it first needs to; after that, ssh-agent
prompts you for credentials only when it needs to open a new key.
If that's not working, make sure you have the correct launchd
configuration file present:
/System/Library/LaunchAgents/org.openbsd.ssh-agent.plist
If it's still not working for you for some reason, here's the "old" way of getting things running by hand:
http://timesinker.blogspot.com/2007/08/getting-ssh-agent-going-on-mac-osx.html
There is also this application, which I have stopped using since Leopard came out but basically did the same thing in previous versions of Mac OS X:
http://www.sshkeychain.org/
Best Answer
In my opinion the best way of using ssh
Before using Git add your key to ssh-agent
Start ssh-agent if not started:
Add your private key using ssh-add
Check if the key is added (parameter is a lowercase L):
Try to connect to your Git server:
Now you can use Git without extra passphrase prompts.
Other ways
https://unix.stackexchange.com/questions/90853/how-can-i-run-ssh-add-automatically-without-password-prompt