git with ssh authentication prompts for password

Hi there,

 

I have enabled SSH keys on my STASH repo, I generated keys, copied the public key into the stash repo, however when I try to do any git operation I am prompted for a password for the git@hostname account.

 

$git pull

git@myhost.mydomain's password: 



If I run the ssh test..


ssh -p 7999 -vT git@myhost.mydomain

OpenSSH_6.9p1, LibreSSL 2.1.8

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: /etc/ssh/ssh_config line 21: Applying options for *

debug1: Connecting to myhost.mydomain[192.168.1.1] port 7999.

debug1: Connection established.

debug1: identity file /Users/myuser/.ssh/id_rsa type 1

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_rsa-cert type -1

debug1: identity file /Users/myuser/.ssh/id_dsa type 2

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_dsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_ecdsa type -1

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_ecdsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_ed25519 type -1

debug1: key_load_public: No such file or directory

debug1: identity file /Users/myuser/.ssh/id_ed25519-cert type -1

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_6.9

debug1: Remote protocol version 2.0, remote software version SSHD-CORE-0.14.0

debug1: no match: SSHD-CORE-0.14.0

debug1: Authenticating to myhost.mydomain:7999 as 'git'

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: server->client aes128-ctr hmac-sha2-256 none

debug1: kex: client->server aes128-ctr hmac-sha2-256 none

debug1: sending SSH2_MSG_KEX_ECDH_INIT

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug1: Server host key: ssh-rsa SHA256:XXXXXXXXXX

debug1: Host '[myhost.mydomain]:7999' is known and matches the RSA host key.

debug1: Found key in /Users/myuser/.ssh/known_hosts:63

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug1: Authentications that can continue: publickey

debug1: Next authentication method: publickey

debug1: Offering DSA public key: /Users/myuser/.ssh/id_dsa

debug1: Server accepts key: pkalg ssh-dss blen 433

debug1: Authentication succeeded (publickey).

Authenticated to myhost.mydomain ([192.168.1.1]:7999).

debug1: channel 0: new [client-session]

debug1: Entering interactive session.

debug1: Sending environment.

debug1: Sending env LANG = en_AU.UTF-8

shell request failed on channel 0

2 answers

1 accepted

Problem solved, ssh:// was missing from my url. Once I put ssh:// at the beginning, git worked.

I'm having the same problem as you were. Adding ssh:// in front of the url doesn't work for me though, as then I just get a message saying "ssh: Could not resolve hostname ...."

To clarfiy, is the correct url format this?

ssh://git@bitbucket.org:[accountname]/[repo].git

 

Mike,

Sounds like you have a DNS issue... did you run the ssh test command like I did? 

Using Bitbucket cloud, running the test:

ssh -Tv git@bitbucket.org

OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Connecting to bitbucket [104.192.143.1] port 22.

debug1: Connection established.

debug1: identity file /c/Users/mikehe/.ssh/id_rsa type 1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_rsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_dsa type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_dsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_ecdsa type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_ecdsa-cert type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_ed25519 type -1

debug1: key_load_public: No such file or directory

debug1: identity file /c/Users/mikehe/.ssh/id_ed25519-cert type -1

debug1: Enabling compatibility mode for protocol 2.0

debug1: Local version string SSH-2.0-OpenSSH_7.1

debug1: Remote protocol version 2.0, remote software version conker_1.0.231.23c31b4 app-126

debug1: no match: conker_1.0.231.23c31b4 app-126

debug1: Authenticating to bitbucket:22 as 'git'

debug1: SSH2_MSG_KEXINIT sent

debug1: SSH2_MSG_KEXINIT received

debug1: kex: server->client aes128-ctr hmac-sha2-256 none

debug1: kex: client->server aes128-ctr hmac-sha2-256 none

debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A

debug1: Host 'bitbucket.org' is known and matches the RSA host key.

debug1: Found key in /c/Users/mikehe/.ssh/known_hosts:1

debug1: SSH2_MSG_NEWKEYS sent

debug1: expecting SSH2_MSG_NEWKEYS

debug1: SSH2_MSG_NEWKEYS received

debug1: Roaming not allowed by server

debug1: SSH2_MSG_SERVICE_REQUEST sent

debug1: SSH2_MSG_SERVICE_ACCEPT received

debug1: Authentications that can continue: publickey

debug1: Next authentication method: publickey

debug1: Offering RSA public key: /c/Users/mikehe/.ssh/id_rsa

debug1: Server accepts key: pkalg ssh-rsa blen 151

Enter passphrase for key '/c/Users/mikehe/.ssh/id_rsa':

debug1: Authentication succeeded (publickey).

Authenticated to bitbucket.org ([104.192.143.1]:22).

debug1: channel 0: new [client-session]

debug1: Entering interactive session.

logged in as mikehe.



You can use git or hg to connect to Bitbucket. Shell access is disabled.

debug1: client_input_channel_req: channel 0 rtype exit-status reply 0

debug1: channel 0: free: client-session, nchannels 1

Transferred: sent 2728, received 1600 bytes, in 0.2 seconds

Bytes per second: sent 16141.2, received 9467.0

debug1: Exit status 0




The test prompts for my password as well ("Enter passphrase for key..."). What am I missing?

Its asking you for a PASSPHRASE 

Enter passphrase for key '/c/Users/mikehe/.ssh/id_rsa':

That is different to a password. What I think might have happened is when you created the public/private key pair and it asked you to encrypt the key with a passphrase, you entered one in..

Have a look at this article:

https://help.github.com/articles/working-with-ssh-key-passphrases/

 

The other option is to generate new keys, when you are prompted to enter a passphrase, just hit enter (blank passphrase), this will work around the issue you have above. Otherwise if you require a passphrase you need to figure out how to pass that to the Bitbucket host during auth.

 

But I don't want to enter a long passphrase every time I use the key!

Neither do I! Thankfully, there's a nifty little tool called ssh-agent that can securely save your passphrase, so you don't have to re-enter it. If you're on OS X Leopard or later your keys can be saved in the system's keychain to make your life even easier. Most Linux installations will automatically startssh-agent for you when you log in.

0 vote

Did you configure a password while generating the SSH key?

You mean a passphrase? No I did not setup a passphrase for the key pair.

I am one step closer to figuring out the problem.. it seems that git is trying to connect to port 22 (trying to bind to the sshd server) rather than the listening java proc on 7999. Looks like this problem is on my git clients side.

 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

2,028 views 1 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you