To fix commands GIT of slow push and pull, when we are using braces
ssh in Github, Gitlab and Bitbucket repository services, it is necessary to change the IP version configuration used.
I like to use connections by HTTPS versioning services and source code repository, mainly due to the convenience of using the services on any machine without the need to create SSH keys for the GIT connection.
However, especially after Github and Bitbucket forced interaction with their repositories through ssh keys, at times connection speed became an issue.
Over the past few days, I've experienced very slow connections when pushing new commits to Bitbucket, mostly via command line shell, SourceTree, or even PHPStorm.
Sending a commit with only one file changed was taking 50 seconds, or even longer, about 3 minutes in some cases.
After debugging the ssh connection in a git push command, the result was something similar to the following:
ssh -Tv [email protected] [...] debug1: Connecting to bitbucket.org [2401:1d80:1010::152] port 22. debug1: connect to address 2401:1d80:1010::152 port 22: Operation timed out debug1: Connecting to bitbucket.org [22.214.171.124] port 22. debug1: Connection established. [...]
If you're not used to IPv6 problems, it didn't jump out to your eyes like it did to mine, the problem: my git installation is trying to use IPv6 instead of IPv4 for the data transfer connections.
Fixing slow GIT with SSH on Github and other services
As I stated in the previous paragraph, the SSH connection via IPV6 is causing the connection to time out, reaching the timeout.
just after this timeout which then IPV4 is used. This was happening every git commit, git pull, or git push.
As a quick fix – I would say definitive, I decided to turn off IPV6 for SSH connections.
To accomplish this, you must open the file
/etc/ssh/sshd_config in your Linux Ubuntu or Mint, and add the following lines:
Host * AddressFamily inet
After restarting the session, your ssh connections will use IPv4 by default and the slowdown will be resolved.
If you want to disable the use of IPv6 in ssh connections on only some specific servers or services, specify the host as in the following example:
Host bitbucket.org AddressFamily inet
In the above configuration I disabled IPv6 over ssh only for Bitbucket servers.
You can do the same for Github or Gitlab servers. Or even for any other service that I access via ssh.