Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4121854
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:24:21+00:00 2026-05-20T23:24:21+00:00

I have gitosis setup on my server and I’m trying to create a post-receive

  • 0

I have gitosis setup on my server and I’m trying to create a post-receive hook that will checkout changes to a working directory on the remote machine.

Initially I got an error saying cannot open /home/user/source/testing-local/.git/FETCH_HEAD: Permission denied so I changed the group ownership of the working directory’s .git folder to the git user.

Following this I got the error Host key verification failed which led me to check which user was running the hook, git of course (silly me!), so I setup a key in gitosis for the git user that gitosis is running under and enabled that in gitosis.conf. Now I’m getting the old Permission denied (publickey).

My post-receive hook looks like this:

#!/bin/bash
while read oldrev newrev refname
do
  if [ "$refname" == "refs/heads/master" ]; then
    WORKDIR=/home/user/source/testing-local
    export GIT_DIR=$WORKDIR/.git
    pushd $WORKDIR >/dev/null
    id
    git pull --quiet >/dev/null
  fi
done

The id call is just to check which user I’m running as.

Is there an easier way to achieve this?! Have I missed something key in my setup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:24:22+00:00Added an answer on May 20, 2026 at 11:24 pm

    You need to make sure of the value of the $HOME environment variable for the git user executing that hook.

    $HOME/.ssh is where ssh will look for the private key during the handshake.
    Also, make sure the ssh directory on the gitosis end has the right permissions.

    server$ chmod go-w ~/
    server$ chmod 700 ~/.ssh
    server$ chmod 600 ~/.ssh/authorized_keys
    

    Finally see the “Permission denied (publickey)” section on GitHub, which repeat what I mentioned above about the HOME:

    This is usually caused when ssh cannot find your keys.
    Make sure your key is in the default location, ~/.ssh.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up a git post-receive hook such that when a commit
I have gitosis setup and working wonderfully using ssh. git@domain.com:repository.git works just as expected.
I have a standard gitosis setup that I would like to backup using rsync.
I'm trying to setup gitosis according to the instructions here . It works fine
I've recently setup an inhouse git repository server and have it up and running
I have gitosis running on my server. My build system needs to get a
I have installed gitosis, but i have strange thing when i'm working with repos.
I have a remote gitosis server and a local git repository, and each time
Have you ever seen any of there error messages? -- SQL Server 2000 Could
I've recently set up cygwin, git, and gitosis on my Windows Server 2003 box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.