ssh: Could not resolve hostname bitbucket.org-{username}: nodename nor servname provided, or
Asked by Irakli Ghachava:

Hi, I have two accounts in bitbucket and I have to SSH keys setup.

Here is my config file

*** ** * ** ***

Host bitbucket.org-{user1}  
HostName bitbucket.org  
User git  
IdentityFile \~/.ssh/nari_ssh  
IdentitiesOnly yes

Host bitbucket.org-{user2}  
HostName bitbucket.org  
User git  
IdentityFile \~/.ssh/delori_ssh  
IdentitiesOnly yes

Host github.com  
HostName github.com  
User git  
IdentityFile \~/.ssh/nari_ssh  
IdentitiesOnly yes  
And this is config in one of my repositories  

*** ** * ** ***

\[user\]  
name = {user1}  
email = {email}  
\[core\]  
repositoryformatversion = 0  
filemode = true  
bare = false  
logallrefupdates = true  
ignorecase = true  
precomposeunicode = true  
\[remote "origin"\]  
url = git@bitbucket.org-{user1}:{company}/dpp-web.git  
fetch = +refs/heads/\*:refs/remotes/origin/\*  
I keep hitting this error

ssh: Could not resolve

hostname bitbucket.org-{user1}: nodename nor servname provided, or not known  
fatal: Could not read from remote repository.

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

This error appeared out of nowhere. The day before it worked fine.

I have correctly checked my public keys in both bitbucket accounts in personal settings and they match.

What could I be doing wrong here?


Answers:
author: Theodora Boudale
body: Hi [@Irakli Ghachava](/t5/user/viewprofilepage/user-id/5246007) and welcome to the community!

Based on the output you posted, the part **bitbucket.org-{user1}** of the repo's URL doesn't seem to be replaced with the host name **bitbucket.org**.

**1.** What operation gives you this error, is it a git push or something else?

**2.** Are you using a command line application or a Git GUI client?

**3.** Can you try performing the same operation from a command line application, adding GIT_SSH_COMMAND="ssh -vvv" before the command, and post the output here so I can take a look?

If you are executing for example a git push, you can run

```
GIT_SSH_COMMAND="ssh -vvv" git push
```

This will show additional output and provide more details on whether a config file is used and which one.

Kind regards,  
Theodora

comments: author: Irakli Ghachava
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086) .

1. git push and git pull. I have not checked the rest

2. CLI

3. This is the output

OpenSSH_9.0p1, LibreSSL 3.3.6  
debug1: Reading configuration data /Users/ika/.ssh/config  
debug1: Reading configuration data /etc/ssh/ssh_config  
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/\* matched no files  
debug1: /etc/ssh/ssh_config line 54: Applying options for \*  
debug3: expanded UserKnownHostsFile '\~/.ssh/known_hosts' -\> '/Users/ika/.ssh/known_hosts'  
debug3: expanded UserKnownHostsFile '\~/.ssh/known_hosts2' -\> '/Users/ika/.ssh/known_hosts2'  
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling  
debug1: Connecting to bitbucket.org-{user1} port 22.  
ssh: Could not resolve hostname bitbucket.org-{user1}: nodename nor servname provided, or not known  
fatal: Could not read from remote repository.

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


author: Theodora Boudale
body: Hi [@Irakli Ghachava](/t5/user/viewprofilepage/user-id/5246007),

Thank you for the info.

Based on the output, it looks like there is an attempt to read the file /Users/ika/.ssh/config, but there is no message for applying options from this file.

Instead, we see that options are being applied from the file /etc/ssh/ssh_config.

**1.** Does the configuration you posted in your first post belong to the file /Users/ika/.ssh/config or to the file /etc/ssh/ssh_config?

**2.** Are you logged in on this computer as the user ika?

**3.** What are the permissions of the directory /Users/ika/.ssh/ and the file /Users/ika/.ssh/config?

Kind regards,  
Theodora


author: Irakli Ghachava
body: 1. It belongs to /Users/ika/.ssh/config

2. Yes

3.

Permissions for /Users/ika/.ssh/

drwx------ 9 ika staff 288 Jun 20 15:12 .ssh

Permissions for /Users/ika/.ssh/config

-rw-r--r-- 1 ika staff 339 Jun 20 15:50 config


author: Theodora Boudale
body: Hi,

Thank you for the info.

The permissions of the file look ok, I am not sure why the configuration is not being applied.

I would suggest trying the following as well for testing purposes:

**1.** Try pushing with the command

```
GIT_SSH_COMMAND="ssh -vvv -F ~/.ssh/config" git push
```

Apart from verbose output, this command specifies that the config file \~/.ssh/config should be used and the system-wide configuration file should be ignored.

Could you then post the output of the command here?

**2.** You can also try copy-pasting the bitbucket entries from \~/.ssh/config into /etc/ssh/ssh_config and see if that helps.

If you do so, please ensure that no identity file is configured for **Host \*** in the /etc/ssh/ssh_config (if it is, you can temporarily comment it out).

Please feel free to let me know how it goes.

Kind regards,  
Theodora


Tags: atl-gruland

bitbucket-cloud

cloud