Skip to end of metadata
Go to start of metadata

Up until this point, you have been using the secure hypertext transfer protocol (HTTPS) to communicate between your local system and Bitbucket. When you use HTTPS, you need to authenticate (supply a username and password) each time you take an action that communicates with the Bitbucket server. You can specify the username in the DVCS configuration file; you don't want to store your password there though where anyone can see it. So, this means you must manually type a password when you use HTTPS with  your local repository. Who wants to do that? This page shows you how to use secure shell (SSH) to communicate with the Bitbucket server and avoid having to manually type a password.

Finally, setting up an SSH identity can be prone to error. Allow yourself some time, perhaps as much as an hour depending on your experience, to complete this page. If you run into issues, check out Troubleshoot SSH Issues for extra information that may help you along. You can even skip this whole page and continue to use HTTPS if you want.

Linux or Mac User?

This page shows you how to set up and use a single default SSH identity on Windows for a Git repository using GitBash. In the next page, you set up SSH for a Mercurial repository on Windows with TortoiseHg. If you are working on Mac OSX or Linux, a single set of instructions shows you how to setup an identity for either Git or Mercurial in these environments.

Step 1. Read a quick overview of SSH concepts

To use SSH with Bitbucket, you create an SSH identity. An identity consists of a private and a public key which together are a key pair. The private key resides on your local computer and the public you upload to your Bitbucket account. Once you upload a public key to your account, you can use SSH to connect with repositories you own and repositories owned by others, provided those other owners give your account permissions. By setting up SSH between your local system and the Bitbucket server, your system uses the key pair to automate authentication; you won't need to enter your password each time you interact with your Bitbucket repository.

There are a few important concepts you need when working with SSH identities and Bitbucket

  • You cannot reuse an identity's public key across accounts. If you have multiple Bitbucket accounts, you must create multiple identities and upload their corresponding public keys to each individual account. 
  • You can associate multiple identities with a Bitbucket account. You would create multiple identities for the same account if, for example, you access a repository from a work computer and a home computer. You might create multiple identities if you wanted to execute DVCS actions on a repository with a script – the script would use a public key with an empty passphrase allowing it to run without human intervention.
  • RSA (R. Rivest, A. Shamir, L. Adleman are the originators) and digital signature algorithm (DSA) are key encryption algorithms. Bitbucket supports both types of algorithms. You should create identities using whichever encryption method is most comfortable and available to you.

Step 2. Check if you have existing default Identity

The Git Bash shell comes with an SSH client. Do the following to verify your installation:

  1. Double-click the Git Bash icon to start a terminal session.
  2. Enter the following command to verify the SSH client is available:

    manthony@MANTHONY-PC ~
    $ ssh -v
    OpenSSH_4.6p1, OpenSSL 0.9.8e 23 Feb 2007
    usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
    [-D [bind_address:]port] [-e escape_char] [-F configfile]
    [-i identity_file] [-L [bind_address:]port:host:hostport]
    [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
    [-R [bind_address:]port:host:hostport] [-S ctl_path]
    [-w local_tun[:remote_tun]] [user@]hostname [command]
  3. If you have ssh installed, go to the next step.
    If you don't have ssh installed, install it now with your package manager.

  4. List the contents of your ~/.ssh directory.
    If you have not used SSH on Bash you might see something like this:

    manthony@MANTHONY-PC ~
    $ ls -a ~/.ssh
    ls: /c/Users/manthony/.ssh: No such file or directory

    If you have a default identity already, you'll see two id_* files:

    manthony@MANTHONY-PC ~
    $ ls -a ~/.ssh
    .    ..    id_rsa    id_rsa.pub  known_hosts

    In this case, the default identity used RSA encryption (id_rsa.pub). If you want to use an existing default identity for your Bitbucket account, skip the next section and go to create a config file.

Step 3. Set up your default identity

By default, the system adds keys for all identities to the /Users/yourname/.ssh directory. The following procedure creates a default identity.

  1. Open a terminal in your local system.
  2. Enter ssh-keygen at the command line. 
    The command prompts you for a file to save the key in:

    manthony@PHOENIX ~
    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Documents and Settings/manthony/.ssh/id_
    rsa):
  3. Press enter to accept the default key and path, /c/Documents and Settings/manthony/.ssh/id_rsa, or you can create a key with another name.
    To create a key with a name other than the default, specify the full path to the key. For example, to create a key called my-new-ssh-key, you would enter a path like this at the prompt:

    manthony@PHOENIX ~
    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Documents and Settings/manthony/.ssh/id_
    rsa): /c/Documents and Settings/manthony/My Documents/keys/my-new-ssh-key
  4. Enter and renter a passphrase when prompted.
    Unless you need a key for a process such as script, you should always provide a passphrase. 
    The command creates your default identity with its public and private keys. The whole interaction looks similar to the following: 

    manthony@MANTHONY-PC ~
    $ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/manthony/.ssh/id_rsa):
    Created directory '/c/Users/manthony/.ssh'.
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/manthony/.ssh/id_rsa.
    Your public key has been saved in /c/Users/manthony/.ssh/id_rsa.pub.
    The key fingerprint is:
    e7:94:d1:a3:02:ee:38:6e:a4:5e:26:a3:a9:f4:95:d4 manthony@MANTHONY-PC
    manthony@MANTHONY-PC ~
    $
  5. List the contents of ~/.ssh to view the key files.
    You should see something like the following:

    The command created two files, one for the public key ( for example id_rsa.pub ) and one for the private key (for example, id_rsa ).

Step 4. Create a SSH config file

  1. Using your favorite text editor, edit an existing (or create a new) ~/.ssh/config file.
  2. Add an entry to the configuration file using the following format:

    Host bitbucket.org
     IdentityFile ~/.ssh/privatekeyfile

    The second line is indented. That indentation (a single space) is important, so make sure you include it.  The second line is the location of your private key file.  If you are following along with these instructions, your file is here:

     ~/.ssh/id_rsa

    When you are done editing, your configuration looks similar to the following:

    Host bitbucket.org
     IdentityFile ~/.ssh/id_rsa
  3. Save and close the file.
  4. Restart the GitBash terminal.

Step 5. Update your .bashrc profile file

It is a good idea to configure your GitBash shell to automatically start the agent when launch the shell.  The .bashrc file is the shell initialization file. It contains commands that run each time your GitBash shell starts.  You can add commands to the .bashrc file that start the agent when you start GitBash. The folks at GitHub have developed a nice script for this (their script was developed from a post by Joseph M. Reagle Jr. from MIT on the cygwin list). To start the agent automatically, do the following.

  1. Start GitBash.
  2. Edit your ~/.bashrc file.

    If you don't have a .bashrc file you can create the file using your favorite text editor. Keep in mind the file must be in your ~ (home) directory and must be named exactly .bashrc.  
  3. Add the following lines to the file:

    Icon

    Chrome and Opera introduce ASCII \xa0 (non-breaking space characters) on paste that can appear in your destination file. If you copy and paste the lines below, copy from another browser to avoid this problem.

  4. Save and close the file.
  5. Close GitBash.
  6. Reopen GitBash.
    The system prompts you for your passphrase:

    Welcome to Git (version 1.7.8-preview20111206)
    Run 'git help git' to display the help index.
    Run 'git help <command>' to display help for specific commands.
    Enter passphrase for /c/Documents and Settings/manthony/.ssh/id_rsa:
  7. Enter your passphrase.
    After accepting your passphrase, the system displays the command shell prompt. 
  8. Verify that the script identity added your identity successfully by querying the SSH agent:

After you install your public key to Bitbucket, having this script should prevent you from having to enter a password each time you push or pull a repository from Bitbucket.

Step 6. Install the public key on your Bitbucket account

  1. Open a browser and log into Bitbucket.
  2. Choose avatar > Manage Account from the menu bar.
    The system displays the Account settings page.
  3. Click SSH keys.
    The SSH Keys page displays. It shows a list of any existing keys. Then, below that, a dialog for labeling and entering a new key.
  4. In your terminal window, cat the contents of the public key file.
    For example:

    cat ~/.ssh/id_rsa.pub
  5. Select and copy the key output in the clipboard.
    If you have problems with copy and paste, you can open the file directly with Notepad. Select the contents of the file (just avoid selecting the end-of-file character).

  6. Back in your browser, enter a Label for your new key, for example, Default public key.

  7. Paste the copied public key into the SSH Key field.
  8. Click the Add key button:

    The system adds the key to your account.
  9. Return to the terminal window and verify your configuration by entering the following command.

    ssh -T git@bitbucket.org

    The command message tells you which Bitbucket account can log in with that key. 

    conq: logged in as tutorials.
    You can use git or hg to connect to Bitbucket. Shell access is disabled.
  10. Verify that the command returns your account name.

     Click if you got a permission denied (publickey) message.

    The command tests your connection to Bitbucket as a Git user. It first sees if your SSH Agent has an identity loaded. The command then checks if that private key matches a public key for an existing Bitbucket account. You might have either problem.

    To make sure your identity is loaded, enter the following command:

    ssh-add -l

    If the identity isn't loaded, check your work in Step 5 above. If it is loaded, try reinstalling your public key on your Bitbucket account. 

    Still having troubles? You can try our Troubleshoot SSH Issues page or email support@bitbucket.org.

Step 7. Configure your repository to use the SSH protocol

The URL you use for a repository depends on which protocol you are using, HTTPS and SSH. The Bitbucket repository Overview page has a quick way for you to see the one for your bb101repo repo. On the repository's Overview page look for the Clone this repository line. 

Experiment for a moment, click back and forth between the SSH and the HTTPS protocol links to see how the URLs differ. The table below shows the format for each DVCS based on protocol.

 SSH URL formatHTTPS URL format
Mercurialssh://hg@bitbucket.org/accountname/reponame/

https://accountname@bitbucket.org/accountname/reponame

Git

git@bitbucket.org:accountname/reponame.git

or

ssh://git@bitbucket.org/accountname/reponame.git

https://accountname@bitbucket.org/accountname/reponame.git

In the SSH format, the accountname appears after git@bitbucket.org or hg@bitbucket.org. In HTTPS format, the accountname before git@bitbucket.org or hg@bitbucket.org.

Go to terminal on your local system and navigate to your bb101repo-practice repository. Then, do the following:

  1. View your current repository configuration.
    You should see something similar to the following:

    manthony@MANTHONY-PC ~ 
    $ cat .git/config
    [core]
      repositoryformatversion = 0
      filemode = true
      bare = false
      logallrefupdates = true
      ignorecase = true
    [remote "origin"]
      fetch = +refs/heads/*:refs/remotes/origin/*
      url = https://newuserme@bitbucket.org/newuserme/bb101repo.git
    [branch "master"]
      remote = origin
      merge = refs/heads/master

     

    As you can see, the url is using the HTTPS protocol. There are a number of ways to change this value, the easiest way is just to edit the repository's configuration file.

  2. Edit the ~/repos/bb101repo-practice/.git/config file with your favorite editor.
  3. Change the url value to use the SSH format for that repository.
    When you are done the origin section should contain something similar to the following:

    [remote "origin"]
      fetch = +refs/heads/*:refs/remotes/origin/*
      url = git@bitbucket.org:newuserme/bb101repo.git
  4. Save your edits and close the file.

Step 8. Make a change under the new protocol

  1. Edit the README file in your bb101repo-practice repository.
  2. Add a new line to the file, for example:

    Welcome to My First Repo
    -------------------------------
    This repo is a practice repo I am using to learn bitbucket.
    You can access this repo with SSH or with HTTPS.
  3. Save and close the file.
  4. Add and then commit your change to your local repo.

    git add README
    git commit -m "making a change under the SSH protocol"
  5. Push your changes.
    The system warns you that it is adding the Bitbucket host to the list of known hosts.

    manthony@MANTHONY-PC ~
    $ git push 
    $ git push
    Counting objects: 5, done.
    Delta compression using up to 2 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 287 bytes, done.
    Total 3 (delta 1), reused 0 (delta 0)
    remote: bb/acl: newuserme is allowed. accepted payload.
    To git@bitbucket.org:newuserme/bb101repo.git
      056c29c..205e9a8 master -> master
  6. Open the repo Overview in Bitbucket to view your commit.

Next Steps

Now, you should set up SSH for Mercurial through the TortoiseHg Workbench. If you are a Mac OSX or Linux user, you should have already worked through one page that covers SSH for both Git and Mercurial.

75 Comments

    1. Anonymous

    2. Anonymous

      thaaaaaanks, it's very helpful

    3. Anonymous

      ok... really thanks...

    4. Thanks for your help here anon. I also had problem getting .bashrc to run auto in step 5, but by adding the following lines to Git bash, my .bashrc file was saved in the right file type and runs sucessfully;

      cd ~ 
      touch
      .bashrc
      notepad
      .bashrc
      1. Anonymous

        Thanks, this finally got me unstuck!

    5. Anonymous

      It didn't work on my PC (windows7 / 64bit).

      How can I work it out?

      1. Hi,

        You can try the script we show in Step 5 above or you can try this script: 

        which others have reported works in Windows 7.  If you still are having problems, please send a note to support@bitbucket.org.

        (I'm in the process of expanding my test environments so as to test both scripts in more environments.)

        Mary

        1. Anonymous

          Hi,

          I tried the above script on Win7 32bit. It showed a success message for the script. I had already changed the origin path in the .git/config file. I also changed the repo settings from https to ssh. I tried 'ssh -T git@bitbucket.org' and I got the message 'Permission denied (publickey)'. So I tried 'ssh-add -l' and got the message 'Could not open a connection to your authentication agent'.

          Please note that my repo is private. Is this the reason? Thanks in advance (smile)

        2. Anonymous

          Hi After Step 5.6

           

          I am not getting this screen after restarting the bash.

           

          Welcome to Git (version 1.7.8-preview20111206)
          Run 'git help git' to display the help index.
          Run 'git help <command>' to display help for specific commands.
          Enter passphrase for /c/Documents and Settings/manthony/.ssh/id_rsa:

           

          Instead I am getting prompt. Can some help what went wrong ?

          I am quite new to this and need to configure ssh for bitbucket for running shell script.

           

          Thanks,

          Vickram

    6. Anonymous

      If your $HOME contains space characters, for example: C:\Documents and Settings\myuser, please use double quote in each ${HOME}, so above script will be as follow:

      1. Anonymous

        Great! It works for me on WinXP. Thanks!

  1. Anonymous

    I'm hung up on Step 4 and I don't want to skip it. Part 1 says "Using your favorite text editor, edit an existing (or create a new) ~/.ssh/config file." I see no config file in my .ssh directory and I don't understand what I'd put into a new config file if I created one (other than the lines that are indicated to enter in Step 4, Part 2.) I realize this must be really basic. 

    1. Hey no worries, SSH can be a showstopper for very experienced people too. If you don't have the config file, you should create one. Then, you put in the lines that appear in Step 4.2 

      Host bitbucket.org
       IdentityFile ~/.ssh/id_rsa

      The id_rsa is the default name for the private key.  If you are following along in this tutorial, you will have this key.  If you keep having problems, send an email to support@bitbucket.org for faster response time and a more personal help.

      1. Anonymous

        For any folks (like me) having trouble "creating" the config file, which should be named "config" not "config.txt": when you save the file in NotePad, name the file "config" with the quotation marks. This will keep NotePad from adding the ".txt".

  2. Anonymous

    Step 5 also did not work for me and I tried following: http://stackoverflow.com/questions/11918285/my-bashrc-file-not-executed-on-git-bash-startup-windows-7 but the same problem still persists, after typing git push I get a long message that says:

    as well as some other stuff that I can't copy and paste. At the end it says

    Anyone know what I'm doing wrong?

  3. Anonymous

    I don't see any .git folder in my repository. So how do I know what's in the config file in .git folder when it doesn't exist.

    Can somebody please point out to me where I'm going wrong?

    1. In Windows, the folder is likely to be hidden. Windows default is to hide these types of files in the view.  Try googling "show hidden files" for your version of Windows.

      1. Anonymous

        Brilliant, thanks. Maybe this should be stated in the tutorial?

  4. Anonymous

    Thanks, great tutorial!!!

  5. Anonymous

    After create .bashrc file and reopen git in step 5,

    I've always the error "Could not open a connection to your authentication agent.".

    initialization ssh agent is succeeded

    someone could help me please?

    1. The link above seems to point back to this page. This link to the Troubleshooting SSH Issues page should work.

  6. Anonymous

    Is that possible that my problem come from the fact that I'm in 64 bits ?

    Because I tried what the site suggested me, but it's still don't work

  7. Anonymous

    Well, I couldn't get past step 5 too, so i had to do some googling. Important part for me was:

    $ eval 'ssh-agent'

    In the example quotes are wrong and i had to use ` (above TAB key) quotes intead of '.

    Then I did :

    $ ssh-add path/to/my/.ssh/id_rsa

    and after i restarded Git Bash, it finaly asked me for pass phrase.

    Also, I had to open id_rsa.pub with text editor, copy/pasting from Git Bash gave me "Invalid SSH key."  error.

    1. Thanks for the info Anon! This helped me as well.*Like*

  8. Anonymous

    here's how i solved step 5 on win xp:

    SSH_ENV="$HOME/.ssh/environment"
     
    function start_agent {
         echo "Initialising new SSH agent..."
         /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
         echo succeeded
         chmod 600 "${SSH_ENV}"
         . "${SSH_ENV}" > /dev/null
         /usr/bin/ssh-add;
    }
     
    # Source SSH settings, if applicable
     
    if [ -f "${SSH_ENV}" ]; then
         . "${SSH_ENV}" > /dev/null
         #ps ${SSH_AGENT_PID} doesn't work under cywgin
         ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
             start_agent;
         }
    else
         start_agent;
    fi

     

    double qoutes everywhere SSH_ENV is used, not sure if they are needed on the definition but they don't hurt.

    1. Anonymous

      This worked for me - I think it was because my home directory ($HOME) referenced my computer username which had a space in it...

      1. Anonymous

        Had this problem too. Should upvote this post or something

    2. Anonymous

      Thanks, this worked for me too! 

  9. Anonymous

    Step 5 still isn't working for me, when I type in `ssh-agent` I get: socket: Invalid argument.

    1. From http://docstore.mik.ua/orelly/networking_2ndEd/ssh/ch12_02.htm:

      Make sure the agent points to a valid socket:

      $ ls -lF $SSH_AUTH_SOCK
      prwx --  --  --    1 smith   0 May 14 23:37 /tmp/ssh-smith/ssh-22719-agent|

      If not, your SSH_AUTH_SOCK variable might be pointing to an old socket from a previous invocation of ssh-agent, due to user error. Terminate and restart the agent properly.

      I'm sorry for the slow update on this page, I'm waiting on some Windows resources to test and try to duplicate all the issues folks run into.

  10. Step5 - When i run the Git bash, it's asking for password for "~ / .ssh/id_rsa" and not for my new created key. How to choose right key in this way?

  11. Anonymous

    I solved Step 4/5 with some of the steps over at github's page:  (https://help.github.com/articles/generating-ssh-keys), helped me through this.  I  replaced the id_rsa - since I couldn't get a new key name to work.  I was having the same problem as Alex D above. 

  12. Anonymous

    Step 5 not work.

  13. Anonymous

    This says its a windows tutorial but 'ssh-keygen' is not a windows command prompt commadn

    1. The tutorial assumes you are entering all your commands in a Git Bash terminal window. Git Bash does provide ssh-keygen.

  14. Anonymous

    First account works fine. But I can't do a git push to my 2nd bitbucket account. It simply says:

    "conq: repository access denied.
    fatal: The remote end hung up unexpectedly"

    When I try: "ssh -T git@bitbucket.org" it connects to the first account.
    How do I get it to connect/use my 2nd ssh key for 2nd account?
    1. The error message indicates that your second account may not have a SSH public loaded. Did you check the SSH settings?

  15. Anonymous

    I have a weird problem - I've passed step 5 successfully. If I make a change and push it, I can see it updating in my panel.

    However, git still asks me for the password, albeit after uploading the changes...

    Isn't it supposed to stop asking me for a password once I setup SSH?

    1. Hmm, if you have uploaded your key to Bitbucket and your shell is configured correctly, it should only ask you once, each time you start GitBash.  You might want to show me the full command input and output...hard to diagnose from a description. The order does seem wrong.

  16. Anonymous

    THUMBS UP my friend

  17. Anonymous

    Is step 5 necessary if you are not using Git Bash on windows, but using terminal on mac?

    1. If you are using terminal on Mac, you should use these instructions which not have this step.

  18. Anonymous

    So, after a bit of confusion I realized if on Linux disregard all the restarting of GitBash!!! I had to: source ~/.bashrc
    ...before I could check: ssh -T git@bitbucket.org

     

  19. I wonder why we go to all this trouble to set up gitbash for Windows, when a Windows user would likely rather use a Windows shell? (I know, heaven help them, but still, it's true). 

    It can be done, using Putty.   

    1. GitBash setup is pretty contained compared with PuTTy.  Another strong benefit of GitBash is that it allows me to write command line examples that work across platforms.

      1. Yes - I too personally heaps prefer gitbash.   However, I have been helping set up an environment for windows users, and they know nothing about unix at all.   This being the case, having a purely windows solution is powerful ... which got me wondering why there isn't more discussion about doing this.   I agree having to set up putty is a bit messy, but then so is the ssh-agent bashrc when you think about it....

  20. Anonymous

    Stucked in step 5. I created the .bashrc file but after restarting GitBash I wasn't asked for my passphrase. When I tried to verify if I have an identity I got the 'The agent has no identities' message. Please help! Thanks.

    1. Anonymous

      Try re-adding the identity:

      ssh-add {path_to_id_rsa_file}

      i.e ssh-add ~/.ssh/id_rsa

       

  21. My user account has spaces in the username (something I try to avoid but that's how our Windows domain is set up), which causes the .bashrc posted above to fail.

    Like "Anonymous" above, I needed to enclose all occurrences of ${SSH_ENV} in double quotes: "${SSH_ENV}".

  22. I can get all of this working, but my question is, isn't the point of using SSH with git so that I don't have to enter a passphrase? I use TortoiseGit and am still prompted from a passphrase at every command when using TortoiseGit. So I end up using a SSH key that is not password protected. Not what I want to do, but I don't want to have to enter the passphrase every instance of running a command via TortoiseGit.

    Does anyone have any suggestions?

    1. What SSH agent are you using Rob?

      1. I am currently just using the ssh client included with msysgit.

        I am on a Windows 7 64-bit workstation with mysysgit 1.8.4 and TortoiseGit 1.8.5.0.

        I can get everything to work okay using Pagent and TortoisePlink, but still need to enter the password when Pagent first runs. In that instance, I have a Pagent startup shortcut that is set to start in my .ssh directory and then load the keys from that directory, though I still need to enter my passcode(s) when I start it.

        This is not a Bitbucket issue. It's a configuration issue on my end and I am just trying to get it running as effectively as possible.

         

  23. Anonymous

    There's something I don't get from this tutorial.

    Suppose this situation: Bob has an bitbucket account with username "Bob" and a repo called "fum". He has given read-only permissions to "fum" to Fred, who has a bitbucket account with username "BigFred". Fred has a windows PC and his account name on this windows PC is "me". Now Fred wants to setup an ssh key for accessing the fum repository from his windos PC without having to type passwords all the time.

    So, where does Fred specify that he wants to use the accountname "BigFred" on bitbucket? It's not in the ssh url, which is git@bitbucket.org:bob/fum.git, it's not "me", it's not inside the ssh key, and it's nowhere in the ~/.ssh folder.

    1. Fred has to log into bitbucket as BigFred and supply the ssh keys to bitbucket.

      Then Fred uses that same key to log into bitbucket - it's BigFred's key, bitbucket can see that.

       

  24. Anonymous

    I was receiving this error in Windows 7 64 bit:

    "ssh: connect to host bitbucket.org port 22: Bad file number"

    It seems that port 22 was blocked.

    I've resolved this problem by adding these lines to config file:

    Host bitbucket.org
     IdentityFile ~/.ssh/id_rsa
     Port 443
     Hostname altssh.bitbucket.org

  25. I was receiving this error in Windows 7 64 bit:

    "ssh: connect to host bitbucket.org port 22: Bad file number"

    It seems that port 22 was blocked.

    I've resolved this problem by adding these lines to config file (please pay attention to 1 space indentation after 1st line):

    Host bitbucket.org
     IdentityFile ~/.ssh/id_rsa
     Port 443
     Hostname altssh.bitbucket.org

  26. Anonymous

    An hour to wade through this setup for windows? What a joke.

  27. What should I do, if  I don't want to use ssh-key id_rsa?

    how to change file .bashrc

  28. Anonymous

    Found another typo, "start the agent when launch the shell." should have "launching" instead.

  29. Anonymous

    @manthony :- https://confluence.atlassian.com/display/~manthony :-

    I mean manthony you gave a great link but seriously it is incomplete and i guess i need help, i wasted around 5 hours now and it is 5 AM in the morning, Please tell me whether the code you gave for the script will ever execute or not

  30. Anonymous

    Like 'everyone' else, I had problems with step 5. Well, it turned out that for me it was actually a problem with step 4: I had mistakenly saved .bachrc in ~/.ssh instead of in ~/  ... after quite a bit of fooling around with adding and removing quotes to the script in the file, simply moving the file to the right location solved the problem. Hopefully this will help someone else.

  31. Anonymous

    This is too many steps for the average user. Is there a quickstart guide I can link to for someone who wants to get up and running with git and bitbucket? I appreciate the in-depth guide, however some people (in the interest of time, or due to language barriers) are not able to digest all this information.

  32. Anonymous

    Pretty laborious, but works perfectly. Thank You.

  33. Step 5.6 only works for me (I am on Windows 7) after I followed this instruction: http://stackoverflow.com/a/17993562/193634

    Otherwise I will get this error:

    The agent has no identities.
    1. Anonymous

      This solved my problem. Thank you

  34. An alternative to step 6.4 and 6.5 would be to send the key contents directly to the clipboard with the following:

    clip < ~/.ssh/id_rsa.pub
  35. Anonymous

    So I'm on the very last step. I've added README to the staging area and committed it to my repo, but I can't do "git push". This is what it tells me when I try to:

    $ git push master
    warning: push.default is unset; its implicit value is changing in
    Git 2.0 from 'matching' to 'simple'. To squelch this message
    and maintain the current behavior after the default changes, use:
    git config --global push.default matching
    To squelch this message and adopt the new behavior now, use:
    git config --global push.default simple
    When push.default is set to 'matching', git will push local branches
    to the remote branches that already exist with the same name.
    In Git 2.0, Git will default to the more conservative 'simple'
    behavior, which only pushes the current branch to the corresponding
    remote branch that 'git pull' uses to update the current branch.
    See 'git help config' and search for 'push.default' for further information.
    (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
    'current' instead of 'simple' if you sometimes use older versions of Git)
    fatal: 'master' does not appear to be a git repository
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    1. Anonymous

      Woops, that was what I tried after git push didn't work. Here's the error I got from git push:

      $ git push
      warning: push.default is unset; its implicit value is changing in
      Git 2.0 from 'matching' to 'simple'. To squelch this message
      and maintain the current behavior after the default changes, use:
      git config --global push.default matching
      To squelch this message and adopt the new behavior now, use:
      git config --global push.default simple
      When push.default is set to 'matching', git will push local branches
      to the remote branches that already exist with the same name.
      In Git 2.0, Git will default to the more conservative 'simple'
      behavior, which only pushes the current branch to the corresponding
      remote branch that 'git pull' uses to update the current branch.
      See 'git help config' and search for 'push.default' for further information.
      (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
      'current' instead of 'simple' if you sometimes use older versions of Git)
      No refs in common and none specified; doing nothing.
      Perhaps you should specify a branch such as 'master'.
      fatal: The remote end hung up unexpectedly
      Everything up-to-date
  36. Anonymous

    I solved this problem by typing

    git config --global push.default matching

    and then

    git push -u origin -all

    (which is what the BB repo overview page says when you click on "I have an existing project to push up.")

    Thanks for this tutorial, manthony!

  37. Anonymous

    I solved this problem by typing

    git config --global push.default matching

    and then

    git push -u origin -all

    (which is what the BB repo overview page says when you click on "I have an existing project to push up.")

    Thanks for this tutorial, manthony!

  38. Thanks for a great tutorial!  I was never able to get step 5 working on my work PC running Windows 7 using any of the scripts mentioned above (sad) Fortunately I still seem to be able to use SSH just fine in Git Bash.  I just wanted to add that when I installed Git on my home PC also running W7 I selected 'run Git from Windows command prompt' instead of 'Git bash only' when I installed and I could use Powershell and SSH just fine with Github and now Bitbucket as well.  Just a note for any other Windows Powershell users having issues.  I'm a newbie to development and I know people seem to not like Powershell, but it's been working just fine for me when it comes to Git.