Permission denied on Git config file

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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

Symptoms

When trying to push to a Repository the following error occurs:

1 2 3 4 5 6 7 8 9 10 11 12 <USER>$ git push origin master Password: Counting objects: 3, done. Writing objects: 100% (3/3), 216 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: warning: unable to access '/home/<USER>/.config/git/config': Permission denied remote: warning: unable to access '/home/<USER>/.gitconfig': Permission denied remote: warning: unable to access '/home/<USER>/.config/git/config': Permission denied remote: warning: unable to access '/home/<USER>/.gitconfig': Permission denied remote: warning: unable to access '/home/<USER>/.config/git/config': Permission denied remote: warning: unable to access '/home/<USER>/.gitconfig': Permission denied To https://<USER>@<HOST>/scm/TEST/test.git

Creating a repository fails with the following error in the atlassian-bitbucket.log:

1 2 3 4 5 6 7 8 9 2014-04-28 15:49:33,094 DEBUG [http-bio-7990-exec-66] admin 949x1214x0 ykug2q 192.168.1.21,127.0.0.1 "POST /projects/TST/repos HTTP/1.1" c.a.s.i.r.RepositoryServiceImpl Could not create repository TST/test [5] com.atlassian.bitbucket.exception.ServerException: An error occurred while executing an external process: '/usr/bin/git init --bare --quiet --shared=false /home/<USER>/atlassian/application-data/bitbucket/data/repositories/5' exited with code 128 saying: fatal: unable to access '/root/.config/git/config': Permission denied at com.atlassian.bitbucket.scm.git.common.command.GitCommandExitHandler.evaluateThrowable(GitCommandExitHandler.java:115) ~[na:na] at com.atlassian.bitbucket.scm.git.common.command.GitCommandExitHandler.onError(GitCommandExitHandler.java:158) ~[na:na] at com.atlassian.bitbucket.scm.DefaultCommandExitHandler.onExit(DefaultCommandExitHandler.java:33) ~[bitbucket-spi-2.12.1.jar:na] at com.atlassian.bitbucket.scm.BaseCommand.callExitHandler(BaseCommand.java:143) ~[bitbucket-spi-2.12.1.jar:na] at com.atlassian.bitbucket.scm.BaseCommand$CommandFuture.internalGet(BaseCommand.java:256) ~[bitbucket-spi-2.12.1.jar:na] ... Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 128

Cause

  1. Git reads config settings from a variety of paths and the <USER> doesn't have access to some of them.

  2. Git tries to read root config setting instead of <USER> config settings due to the starting script using su command with do not reset environment variables option (-m):

    1 /bin/su -m $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"
  3. Bitbucket Server is being started as root with /etc/init.d/atlbitbucket start script. Since the init.d script calls start-bitbucket.sh which uses su -m this causes the environment variables for root to be preserved and atlbitbucket does not have permission to write in the root home directory.

  4. Git was compiled from source using the default settings which prevents any users other than the one that compiled Git from running it

  5. Bitbucket Server is being started on privileged ports (443 for instance) using external tools such as authbind. Due to that the child processes being spawned by Bitbucket to run git will run with privileged permissions and cause the warning on the client-side.

Resolution

  1. Fix the permissions on the files and directories with regard to the Bitbucket Server user performing the command:

    1 2 chown <USER>.<GROUP> -R /home/<USER>/.config chown <USER>.<GROUP> -R /home/<USER>/.gitconfig

    ℹ️ Change the USER.GROUP by your username and group in your OS.

    ℹ️ It may be necessary to change the permissions in the folders above by granting the Bitbucket user read access to /root and write access to root/.config.

  2. If Bitbucket Server starting script have su command, make sure that the option -m is not used.

  3. If Bitbucket Server is being started with /etc/init.d/atlbitbucket start switch to starting Bitbucket Servering with service atlbitbucket start

    1. To have Bitbucket Server automatically start at boot, run chkconfig atlbitbucket on

  4. Recompile Git using more sensible defaults:

    1 2 make prefix=/usr/local/git all make prefix=/usr/local/git install
Updated on April 17, 2025

Still need help?

The Atlassian Community is here for you.