Frequent ssh connection failure to github

I am noticing my jenkins jobs failing frequently but not consistently. It might be an internal firewall issue but i wanted to check if anyone can point me to something that i haven’t checked so far. The jenkins jobs, involves:
1. a git fetch &
2. a git tag

The jobs either fails at #1, if it succeeds in #1 it sometimes fails at #2 Else the job is successful.

The console log, when it fails on #1:

> git fetch --tags --progress git@github.com:myorganization/myproject +refs/heads/*:refs/remotes/origin/*
FATAL: Failed to fetch from git@github.com:myorganization/myproject
hudson.plugins.git.GitException: Failed to fetch from git@github.com:myorganization/myproject
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:627)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:865)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:890)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1259)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
    at hudson.model.Run.execute(Run.java:1759)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@github.com:myorganization/myproject +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

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

And console output it fails @ #2

Updated data_bag_item[dev::dev]
tagging git for env dev
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error occured:
  AutoTagger::Git::Repo::GitCommandFailedError (AutoTagger::Git::Repo::GitCommandFailedError)
/opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/lib/auto_tagger/git/repo.rb:58:in `exec'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/lib/auto_tagger/git/ref_set.rb:36:in `fetch'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/lib/auto_tagger/base.rb:40:in `fetch'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/lib/auto_tagger/base.rb:33:in `create_ref'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/lib/auto_tagger/command_line.rb:49:in `execute'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/gems/auto_tagger-0.2.10/bin/autotag:5:in `<top (required)>'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/bin/autotag:23:in `load'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/bin/autotag:23:in `<main>'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/bin/ruby_executable_hooks:15:in `eval'
  /opt/mount1/rvm/gems/ruby-2.1.1@oss/bin/ruby_executable_hooks:15:in `<main>'
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered

..
I have 2 jenkins slaves with this issue, i build another jenkins slave and the 3rd also shows the similiar issue. Below are the things that i have verified:

  1. The jenkins user, who performs the build job have the right RSA private key for the public key in the github account. I can do a ssh -T git@github.com just fine.

    [jenkins@slave3 ~]$ ssh -T git@github.com
    Hi myaccount! You’ve successfully authenticated, but GitHub does not provide shell access.

  2. Below is the /home/jenkins/.ssh/config file

    Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/myprivate-key
    StrictHostKeyChecking no

i have tried to use port 443 for the ssh connection but my network doesn’t seem to like it. Before i change the config file to use port 443, i test manually with the command

ssh -T -p 443 git@github.com
  1. I have created a basic shell script and let it ran for every 10secs. It picked up ssh connection failures but not as frequently as i am encountering on the jenkins.

Note: please dont mark this as dup. i have looked up some of the connection issues to github like these:

Jenkins: Failed to connect to repository

Can't authenticate with GitHub

But they are not even remotely similiar

Git Baby is a git and github fan, let's start git clone.