Git push over SSH - User session has timed out idling after 600000 ms.
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
Sometimes pushing large changesets in a Git repository over SSH (common when doing the first push on a newly created repository) fails due to idling timeout.
The following appears in the git command output:
$ git push -u origin master
16:32:03.160072 git.c:350 trace: built-in: git 'push' '-u' 'origin' 'master'
16:32:03.222659 run-command.c:336 trace: run_command: 'ssh' '-p' '7999' 'git@10.0.0.2' 'git-receive-pack '\''/tst/repository.git'\'''
Enter passphrase for key '/c/Users/username/.ssh/id_rsa':
16:32:11.773693 run-command.c:336 trace: run_command: 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
16:32:11.873262 git.c:350 trace: built-in: git 'pack-objects' '--all-progress-implied' '--revs' '--stdout' '--thin' '--delta-base-offset' '--progress'
Counting objects: 22632, done.
Delta compression using up to 4 threads.
Received disconnect from 10.0.0.2: 2: User session has timed out idling after 600000 ms.
Disconnected from 10.0.0.2
fatal: The remote end hung up unexpectedly
Compressing objects: 100% (21794/21794), done.
fatal: sha1 file '<stdout>' write error: Broken pipe
error: failed to push some refs to 'ssh://git@10.0.0.2:7999/tst/repository.git'
Cause
The reason for the failure could be due to the fact that while pushing on Bitbucket the server needs to perform background operations and the SSH connection will remain idle for long time, hence causing the timeout.
Workaround
Huge pushes are not common in the usual Git workflow, so it is better to avoid altering the Bitbucket server backend SSH configuration.
It is possible to tweak the configuration of the client workstation to modify the ServerAliveInterval
for SSH connection.
ServerAliveInterval will send a null packet to the remote server every x seconds to keep the connection alive:
Open the SSH config file (or crete it if it does not exist) on your client workstation:
Add the following section to the file:
Host * ServerAliveInterval 30 ServerAliveCountMax 4
- Perform again the push operation.