This should be related to your ssh key format, as illustrated by this thread.
I used PuttyGen on Windows to generate my public key (SSH2 RSA 1024) and save it locally, and then I uploaded it to /tmp/id_rsa.pub using pscp, but then when I ran
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
I kept getting errors, eg:
gitosis.init.InsecureSSHKeyUsername: Username contains not allowed characters: ‘—‘
or:
gitosis.init.InsecureSSHKeyUsername: Username contains not allowed characters:’”rsa-key-20081202”’
or (after I got rid of everything in the file but the key itself):
ValueError: need more than 1 value to unpack
I figured that PuttyGen had generated an SSH2 public key file in a slightly different format, and ‘git gitosis-init’ wanted a user name at the beginning, so I went here:
http://www.rfc-archive.org/getrfc.php?rfc=4716
and saw that I could keep the “—BEGIN…” and “—END” parts, and replace the “comment: ...” line (generated by PuttyGen) with a line reading:
subject: git
And it worked! I got the output:
Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/
Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/