HEKTO
HEKTO

Reputation: 4191

Git configuration to pull/push WITH password

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:

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.

Upvotes: 2

Views: 1594

Answers (2)

Dong Thang
Dong Thang

Reputation: 418

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

Upvotes: 1

VonC
VonC

Reputation: 1323553

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.

Upvotes: 2

Related Questions