2

I'm running Ubuntu 14.04 virtual machine on Macbook Pro using the VMware Fusion. My git repository can be accessed from OSX and from Ubuntu (as shared directory) as well, however the git communication with BitBucket works differently - the git pull and git push commands ask for password in Ubuntu, but they work without password in OSX.

Configuration files:

  • The /etc/gitconfig file is absent in both cases
  • The ~/.gitconfig file content is the same in both cases
  • The .git/config file is physically the same

Git version on Ubuntu is 1.9.1, and on OSX - 1.9.5.

Where should I look to find out the reason for this difference? I'd actually prefer entering password in OSX as well, because it's a semi-private machine.

HEKTO
  • 3,876
  • 2
  • 24
  • 45

2 Answers2

2

Where should I look to find out the reason for this difference?

It depends on the url used (output of git remote -v)

  • https: the OSX session might have cached the password with the oskeychain helper.
    You would need a cache credential helper in Ubuntu to achieve the same result.

  • ssh: git is looking for the ssh keys in ~/.ssh, which can be properly set in the Mac OSX session, but empty in the Ubuntu VM.
    You would need the same keys in the Ubuntu ~/.ssh folder in order to avoid ssh to fall back to a username/password authentication.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • My remote repo is configured with `https:`, and this configuration is the same for both cases, because there is actually a single `.git/config` file. Nevertheless I've synced both `.ssh` dirs just in case. I'll check the `oskeychain` helper, but I actually need authentication *with password* - thanks! – HEKTO Jun 06 '16 at 23:42
  • @HEKTO If the MAc OSX session does *not* ask for a password, it means said password is cached in a way which is not accessible by the Ubuntu session. – VonC Jun 06 '16 at 23:44
  • @HEKTO If you actually need authentication with password, you can clear up that cache: https://help.github.com/articles/updating-credentials-from-the-osx-keychain/ (http://stackoverflow.com/q/11067818/6309) – VonC Jun 06 '16 at 23:46
1

Please use SSH to pull/push without password.

Refer: https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

When you use HTTPS, you authenticate (supply a username and password) each time you take an action that requires a connection with Bitbucket. 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 all the time.

Step 1: Gen ssh key, From the Terminal or Git Bash

ssh-keygen 

Step 2: Confirm the default path .ssh/id_rsa Enter a passphrase (recommended) or leave it blank. Remember this passphrase, as you will need it to unlock the key whenever you use it.

Step 3: Open ~/.ssh/id_rsa.pub and copy & paste the contents into your server.

Note that id_rsa.pub is your public key and can be shared, while id_rsa is your private key and should be kept secret.

Step 4: Re-Check, in Git Bash type

ssh -p 29418 YOUR_NAME@YOUR_SERVER.com

to check result. if success

**** Welcome to Gerrit Code Review ****

Hi , you have successfully connected over SSH.

git clone ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git

Step 5: Change remote directory of git. Type in Git Bash to replace your link.

git remote set-url origin ssh://YOUR_NAME@YOUR_SERVER.com:29418/REPOSITORY_NAME.git
Dong Thang
  • 410
  • 6
  • 6