I made my own git repo on my server using git init --bare
. I added some files there and then cloned my repo from myserver by git clone http://www.example.
Try to add this to your config file in the bare repository:
[http]
receivepack = true
/repo/.ssh/authorized_keys
won't mean anything to your ssh daemon on your server: sshd will look for that file under the home of the user making the ssh query: /home/user/.ssh/authorized_key
Plus, if you are using https://... urls, you won't use ssh at all anyway. For an ssh url to work, you would need an Apache server properly configure to call the git-http-backend script.
See for instance this git-http-backend question.
That is because you cloned using the http url and not the ssh url that is present on Github. And now you are trying to push using ssh which will not work. In such cases, git clone or git pull works but git push fails.
One solution is to clone using the ssh url which will be of the form git@github.com:username/repo-name.git You can find this url on ur Github repo when you click on SSH in "You can clone with HTTPS, SSH, or Subversion" message. And then make changes and do a git push. Make sure that the public key for your machine is present in your Github account.
Another way for the current situation to work would be to supply username and password when doing a Git push.
Just for the record, because this comes up high on google when searching "git-http-push failed return code 22":
With https git and htpasswd on the server, it seems that the user name sent includes the domain: user@domain.tld
, but the expected name is only user
.
The solution for me was to add this in ~/.netrc
:
machine host.domain.tld
login the_user_name
password the_password
The trick for me was to enable WebDAV
I put it in LocationMatch:
<LocationMatch /git/.*\.git>
Dav On
AuthType Basic
AuthName "Git Verification"
AuthUserFile /etc/httpd/git/test.passwd
Require valid-user
</LocationMatch>