ssh: connect to host bitbucket.org port 22: Connection timed out

user3489502 picture user3489502 · Oct 27, 2015 · Viewed 14.4k times · Source

Everything was working perfectly fine. Did some git pushes with no problems.

Today I decided to update my framework to the latest version, so it changed the directory structure of my project a bit. So within Bitbucket, I created a new repository (dev1.project.com) and renamed my project's folder from OldName to dev1.project.com.

I edited .git/config to point my new repository:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[branch "master"]
[remote "origin"]
        url = https://bitbucket.org/user/dev1.project.com.git
        fetch = +refs/heads/*:refs/remotes/origin/*

When I do git remote -v, I get :

origin  ssh://[email protected]/user/dev1.project.com.git (fetch)
origin  ssh://[email protected]/user/dev1.project.com.git (push)

I go back to my project folder, and type:

git init
git add .      
git commit -m 'my first commit'
git push -u origin master

but I keep getting the following error:

ssh: connect to host bitbucket.org port 22: Connection timed out
fatal: The remote end hung up unexpectedly

The command ssh -T [email protected] gets me the same messages as above.

The command: git config --get remote.origin.url shows:

[email protected]:user/dev1.project.com.git

status.bitbucket.org shows that everything works fine on their side.

Not sure why it was working before, and not working now.

I'm on CentOS and i'm not sure what I should do next. I've seen a couple iptables-related answers, so I tried this:

iptables -t filter -A OUTPUT -p tcp --match multiport --dport 22 -j ACCEPT

service iptables stop
service ip6tables stop
service sshd reload
service iptables start
service ip6tables start

But still nothing, any ideas?

Ps: I've also updated CentOS from 6.6 to 6.7 and PHP 5.4 to 5.6, but didn't think it would matter.

Update #1

Ran the following commands:

ps x | grep ssh-agent
eval `ssh-agent -s`
ssh-add     # then it asked for my password

Got the message:

Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

Then

service sshd restart

But still nothing

Update #2

I email my VPS hosting company, asking if there is anything I can do to open port 22, and they answered:

I have disabled the monitoring system on the host node blocking traffic to Bitbucket.

I don't know what it means, but everything was working after that, and apparently I couldn't do anything about it.

Answer

Pardeep Kumar picture Pardeep Kumar · Sep 29, 2017

I have done below mentioned things and it started working.

 vim ~/.ssh/config

Add these lines and save it.

Host bitbucket.org
Hostname  altssh.bitbucket.org
Port  443