user5878968
user5878968

Reputation: 121

SSH won't connect after asking about host authenticity

I'm having a problem; git returns this alert:

The authenticity of host 'bitbucket.org (104.192.143.2)' can't be established.
RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1
Are you sure you want to continue connecting (yes/no)?

When I choose yes, it returns this:

Warning: Permanently added 'bitbucket.org,104.192.143.2' (RSA) to the list of known hosts.
ssh_packet_read: Connection closed
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What is the problem?

Where must I add the RSA number? Please, I'm desperate. :(

Upvotes: 9

Views: 37024

Answers (3)

Kumanan
Kumanan

Reputation: 441

Make sure you have followed below steps in your application server:

Have you created public key:

cd ~/.ssh/

To generate keygeneration:

ssh-keygen

Copy public key value (NOT PRIVATE KEY)

cat ~/.ssh/id_rsa.pub

Install git :

sudo apt install git

ATLASSIAN SETUP :

SETTINGS -> Access keys -> Add key

https://bitbucket.org/compassitesinc/your-repository/admin/access-keys/

Make sure your email address added to the User group (with admin permission)

SETTINGS -> User and group access

Add your email address with admin access

Inside your application root directory clone your repository.

cd /var/www/html/

git clone [email protected]:organization_name/repo_application.git repo_application

Upvotes: 12

lucasjohnson
lucasjohnson

Reputation: 169

You need to create an SSH key on the machine you wish to connect to GitHub or Bitbucket, then add that key to your online account. You can do this by following this:

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

Upvotes: 4

Schwern
Schwern

Reputation: 165586

The authenticity of host 'bitbucket.org (104.192.143.2)' can't be established. RSA key fingerprint is SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1 Are you sure you want to continue connecting (yes/no)?

This is normal and it's safe to say yes. ssh is being overly paranoid by asking you to confirm it. You can turn it off by setting StrictHostKeyChecking to no in your ssh config.

Remembering the public key of each server you connect to is a security feature of ssh to protect you from a man-in-the-middle attack. It goes something like this:

The first time you ssh to a host its public key (that's all that SHA256:zzXQ... stuff) is remembered, usually in ~/.ssh/known_hosts.

Every time thereafter ssh will check that the same host is still using the same key. This authenticates that bitbucket.org is still the same server you were talking to the first time.

If the keys don't match it could mean one of two things. First is that the server admin reinstalled their ssh server and forgot to keep the same key. This is common for small sites, but unlikely for something like bitbucket.org.

The second possibility is that the ssh server has been hijacked. It doesn't matter how. One common way is for a rogue DNS server to return their own malicious IP address instead of the real address for bitbucket.org. Common enough on public wifi connections.


As for why it won't connect after confirming, it's right there in the error message.

$ git clone [email protected]:RobeJablonski/sda-robert.git
Cloning into 'sda-robert'...
conq: repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The repository exists, that can be verified, so you don't have access rights (neither do I). Bitbucket determines who you are using your ssh key. This means you're not logging in with the right key. It has to be the same key as is associated with your account on BitBucket.

You can find your BitBucket ssh keys in your Bitbucket settings under https://bitbucket.org/account/user//ssh-keys/. Then you have to check if ssh is using that key. You can check what it's using using ssh -v [email protected]. It will spew out a lot of stuff but you're looking for the last instance of debug1: Offering RSA public key: /Users/blah/.ssh/blah.

Once you find that, check if /Users/blah/.ssh/blah.pub matches what BitBucket thinks your ssh key is. If they don't match, then you'll have to find the matching key and configure ssh to use that key for bitbucket.org.

If you've lost the key, you should change your ssh key on bitbucket.org.

Upvotes: 11

Related Questions