Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ssh could not resolve hostname

Tags:

git

ssh

proxy

If I want to clone a Git repository via SSH, I get:

ssh: Could not resolve hostname bitbucket.org: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

I need to use a proxy to connect to the internet. (proxy:8080)

In Git I can easily set the HTTP and HTTPS proxy via:

git config --global http.proxy http://proxy:8080/
git config --global https.proxy http://proxy:8080/

How can this be achieved for SSH?

like image 383
Niklas Avatar asked Oct 29 '25 16:10

Niklas


2 Answers

SSH doesn't work with an HTTP/HTTPS proxy. If your proxy supports SOCKS, you may be able to use git via SOCKS using a wrapper like tsocks or socksify or a redirection tool like redsocks. Those are options for Linux; on Windows maybe something like Widecap will help. Here's a more comprehensive overview of tools that may be suitable: https://en.wikipedia.org/wiki/Comparison_of_proxifiers

Alternatively, Git supports HTTP, too, and so does BitBucket, as far as I know. Hence, it might be worth trying the URL with https:// instead. Example: https://youruser@bitbucket.org/youruser/yourrepository.git

like image 166
Jan Krüger Avatar answered Oct 31 '25 05:10

Jan Krüger


I faced similar issue and landed up here. In my case one of my local gitlab project was throwing below error for push/pull. Other gitlab projects under same group were working fine.

ssh: Could not resolve hostname gitlab.com: nodename nor servname provided, or not known.

Fix :

In file <PROJECT_FOLDER>/.git/config url was like url = ssh://[email protected]

Removing ssh:// from url worked for me.

like image 31
swaz Avatar answered Oct 31 '25 05:10

swaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!