Kallithea issues archive

Issue #148: error in hook during the `git push` via SSH

Reported by: Oleg Pivovarov
State: new
Created on: 2015-07-23 11:36
Updated on: 2016-02-19 06:36


I deployed the Kallithea, and clone the bare git repository via ssh.

git clone ssh://git@

During the "git push", I get an error:

> git push origin master
Enter passphrase for key '/home/r2d2/.ssh/id_rsa': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 184 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Traceback (most recent call last):
remote:   File "hooks/pre-receive", line 34, in <module>
remote:     main()
remote:   File "hooks/pre-receive", line 30, in main
remote:     _handler(repo_path, push_data, os.environ)
remote:   File "/srv/www/htdocs/Kallithea-0.2.1/kallithea/lib/hooks.py", line 373, in <lambda>
remote:     handle_git_receive(repo_path, revs, env, hook_type='pre'))
remote:   File "/srv/www/htdocs/Kallithea-0.2.1/kallithea/lib/hooks.py", line 396, in handle_git_receive
remote:     extras = _extract_extras(env)
remote:   File "/srv/www/htdocs/Kallithea-0.2.1/kallithea/lib/utils2.py", line 644, in _extract_extras
remote:     raise Exception('Missing key %s in os.environ %s' % (e, rc_extras))
remote: Exception: Missing key 'username' in os.environ {}

how to fix it?



Comment by Oleg Pivovarov, on 2015-07-23 11:37

Comment by Oleg Pivovarov, on 2015-07-23 11:40

Comment by Mads Kiilerich, on 2015-07-23 11:46

Kallithea doesn't have ssh support yet.

It is possible the git hooks somehow should handle direct access without Kallithea - I don't know what that should be.

Comment by Teemu Vesala, on 2016-02-16 11:40

There is workaround if you don't need Kallithea's access control. This is short instructions how we I managed to get it working. NOTE! If you have strict security requirements, store the API key outside the hooks directory. This is still our proof of concept, and security is not considered. 1) Remove the hooks 2) Create the API key with the user who has admin rights 3) Create the following kind post-receive hook:

#!/usr/bin/env bash
# If you are using virtual environment, activate it. Otherwise remove the next line.
source /path/to/kallithea-venv/bin/
# Invalidates the cache of the repository. If your Kallithea is not at port 5000, change the apihost value.
kallithea-api --apihost= --apikey=<API KEY> invalidate_cache repoid:<REPOSITORY NAME>

Hopefully this helps you to proceed. This seems to work, but I still can't give 100% guarantee.

Comment by Mads Kiilerich, on 2016-02-16 16:39

Have you tried paster update-repoinfo my.ini --invalidate-cache --update-only=path/to/repo

Comment by Teemu Vesala, on 2016-02-19 06:36

Yes. That works. Thanks. So change the last line with that. Security risks are reduced right away.