After moving Bamboo to another drive, Git SSH authentication stops working in Windows

Still need help?

The Atlassian Community is here for you.

Ask the community

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

  • Bamboo running on Windows
  • Originally installed at C:\Program Files\Bamboo and gets moved to another drive in which the path also contains spaces (e.g., E:\Program Files\Bamboo)
  • Source Code Checkout tasks that are executed against Git / Stash / Bitbucket Server using SSH authentication stop working.
  • Git for Windows is being used.
  • The following error message is written in atlassian-bamboo.log:

    2016-01-26 15:44:34,162 INFO [4-BAM::PlanExec:pool-8-thread-4] [RetryingTaskExecutor] Task 'Collecting changes for ABC-DE' was unsuccessful. Run 1 / 2. Exception thrown when running task 'Collecting changes for ABC-DE', with message: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command E:\Git\cmd\git.exe ls-remote ssh://ac989a34-4421-4205-9cab-986ed9af6bdd@127.0.0.1:50103/pp/mygitrepo.git failed with code 128. Working directory was [.]., stderr:
    ['E:\Program' is not recognized as an internal or external command,, operable program or batch file., fatal: Could not read from remote repository., , Please make sure you have the correct access rights, and the repository exists.]
    2016-01-26 15:44:39,516 INFO [4-BAM::PlanExec:pool-8-thread-4] [RetryingTaskExecutor] Task 'Collecting changes for ABC-DE' was unsuccessful. Run 2 / 2. Exception thrown when running task 'Collecting changes for ABC-DE', with message: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command E:\Git\cmd\git.exe ls-remote ssh://bfe2cb88-58d2-43e1-8485-d070707d925e@127.0.0.1:50103/pp/mygitrepo.git failed with code 128. Working directory was [.]., stderr:
    ['E:\Program' is not recognized as an internal or external command,, operable program or batch file., fatal: Could not read from remote repository., , Please make sure you have the correct access rights, and the repository exists.]
    2016-01-26 15:44:39,517 ERROR [4-BAM::PlanExec:pool-8-thread-4] [RetryingTaskExecutor] Failed to run task 'Collecting changes for ABC-DE' after 2 attempts. Task was not executed.
    2016-01-26 15:44:39,517 ERROR [4-BAM::PlanExec:pool-8-thread-4] [RetryingTaskExecutor] Exception being rethrown
    2016-01-26 15:44:39,519 INFO [4-BAM::PlanExec:pool-8-thread-4] [DefaultErrorHandler] Recording an error: Unable to detect changes : ABC-DE : java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.git.GitCommandException: command E:\Git\cmd\git.exe ls-remote ssh://bfe2cb88-58d2-43e1-8485-d070707d925e@127.0.0.1:50103/pp/mygitrepo.git failed with code 128. Working directory was [.]., stderr:
    ['E:\Program' is not recognized as an internal or external command,, operable program or batch file., fatal: Could not read from remote repository., , Please make sure you have the correct access rights, and the repository exists.]

Diagnosis

Environment

  • Windows
  • Using Git for Windows
  • Using SSH authentication against Git repositories

Diagnostic Steps

  • Run Command Prompt as Administrator and execute the following command: 

    C:\Users\Administrator>fsutil 8dot3name query C:
    The volume state is: 0 (8dot3 name creation is enabled).
    The registry state is: 2 (Per volume setting - the default).
    Based on the above two settings, 8dot3 name creation is enabled on C:

    As can be seen above, 8.3 name creation is enabled in C:\ drive. This means that paths that contain spaces, such as C:\Program Files\Bamboo, get automatically converted to C:\Progra~1\Bamboo.
    This allows Bamboo to prepare a shortened path of its temp directory (i.e., convert C:\Program Files\Bamboo\temp into
    C:\Progra~1\Bamboo\temp)
    The temp directory contains the SSH keys that are used by Git for Windows in order to checkout source code.
     

  • Now execute the same command against E:\ drive:

    C:\Users\Administrator>fsutil 8dot3name query E:
    The volume state is: 1 (8dot3 name creation is disabled).
    The registry state is: 2 (Per volume setting - the default).
    Based on the above two settings, 8dot3 name creation is disabled on E:

    As can be seen above, 8.3 name creation disabled in E:\ drive. Due to that, paths that contain spaces cannot be converted into their shortened paths without spaces, causing the issue reported in the logs.

Cause

8.3 name creation is disabled in the drive into which Bamboo was moved.

Resolution

There are two ways of solving this problem:

Easiest way:

  1. Stop Bamboo;
  2. Add the -Djava.io.tmpdir argument this way:
    1. If Bamboo is started manually (by running <BAMBOO_INSTALL>\bin\start-bamboo.bat or <BAMBOO_INSTALL>\bin\startup.bat):
      1. Add the following to <BAMBOO_INSTALL>\bin\setenv.bat:

        set JVM_SUPPORT_RECOMMENDED_ARGS="-Djava.io.tmpdir=E:\Bamboo\temp"
        

        The idea is to set up a path to a temp directory without spaces

      2. Save and close the file. 
    2. If Bamboo is started as Windows service:
      1. Identify the name of the service that Bamboo is installed as by going to Control Panel >> Administrative Tools >> Services.
      2. Right click on the Bamboo service and select "Properties"
      3. The name of the service is shown after "Service name"
      4. Open Command Prompt, then cd to the BAMBOO_INSTALL\bin directory.
      5. Run tomcat7w //ES//%SERVICENAME%
      6. Click on the Java tab and add the following to the list of current startup options:
        -Djava.io.tmpdir=E:\Bamboo\temp

        Note: Each option must be on its own line. The idea is to set up a path to a temp directory without spaces
      7. Apply the changes.
  3. Start Bamboo

Hardest way:

  1. Stop Bamboo;

  2. Identify the volume name of E:\ drive: 

    C:\Users\Administrator>mountvol E: /L
       \\?\Volume{328595dc-322b-11e5-80b1-806e6f6e6963}\

    Note: more information about mountvol syntax can be found here.

  3. Enable 8.3 on E:\ drive by running the following command:

    C:\Users\Administrator>fsutil behavior set disable8dot3 Volume{328595dc-322b-11e5-80b1-806e6f6e6963} 0 
    Successfully enabled 8dot3name generation on Volume{328595dc-322b-11e5-80b1-806e6f6e6963}
    

    Note: more information about fsutil syntax can be found here.

  4. Start Bamboo

 

 

Last modified on Feb 3, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.