5

At this moment I've got one git repo added through gitosis. The manual i used is http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

  1. I can clone it and push in it via ssh auth with private and public keys (on gentoo), but windows users which are using Git Extensions can not. SSH keys placed in $HOME/.ssh, and ssh asks for a password. Nor password, nor passphrase (from private ssh key) don't match.

  2. Redmine needs for a bare repo, so i cloned repo from gitosis on my local machine and moved it to server (redmine + git), then tried to sync like showed here http://www.redmine.org/projects/redmine/wiki/HowTo_keep_in_sync_your_git_repository_for_redmine But it asks for a password again! Of course I didn't make apache his own ssh keys to auth gitosis =_= (Apache is owner of redmine bare repo, cause it access it through http auth)

Anyway the question is how to use private ssh key from file when accessing to gitosis?

===

Partially solved! ssh-keygen -t rsa generates keys, which names are exactly id_rsa and id_rsa.pub. if you run ssh -vvv gitosis@your-server.com you should see something similar to

debug1: Authentications that can continue: publickey,keyboard-interactive
…
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: user@domain-user
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /home/user/.ssh/id_rsa
debug3: no such identity: /home/user/.ssh/id_rsa
debug1: Trying private key: /home/user/.ssh/id_dsa
debug3: no such identity: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug3: no such identity: /home/user/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive

So, ssh client wants exactly named files or will switch to next auth method (password). Now i renamed keys on my home machine and:

user@home ~ $ git clone ssh://git@your-gitosis-server/reponame.git
Cloning into reponame...
Enter passphrase for key '/home/user/.ssh/id_rsa':

Hurray, it asks for a passphrase! BTW, ШIИDOШS™ users are still having problems with their tens of generated keys.

Upd

If you use OpenSSH, then in ~/.ssh you may create a file named ‘config’ and put there something like this:

Host mygitosisserver.com
IdentityFile ~/.ssh/private-key-for-mygitosisserver-com
tijagi
  • 1,124
  • 1
  • 13
  • 31

2 Answers2

4

Windows users should be able to clone as well (with ssh), if they have defined the %HOME% environment variable.
HOME isn't defined by default.
It can reference any directory they want (usually, one takes the same than %HOMEPATH%)


The OP user685107 reports:

Problem with windows users was solved by strictly following the manual of key generation with puttygen.
new key pair maked in windows works fine

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • That's because there is git.cmd (kind of pre-init in Git Extensions) with `@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%`, so %HOME% is set in git environment. Still, how to import ssh keys? I've come back to home and placed my ssh keys from workstation to ~/.ssh, trying to clone `git clone ssh://git@my_host/gitosis-admin.git` and caught prompt asking for password (usually a window asking for a _passphrase_). – tijagi Jul 19 '11 at 19:38
  • @user685107: that seems normal if you have generated your private key with a passphrase. In that case: http://stackoverflow.com/questions/370030/git-cant-remember-my-passphrase or http://stackoverflow.com/questions/6106137/git-enter-long-passphrase-for-every-push – VonC Jul 19 '11 at 20:16
  • Of course the keys were generated with passphrases. But Putty makes keys a way incompatible with OpenSSH server. So i generated them on the same server for Windows™ users. They aren't issue problems, except the connection always asks for a **password instead of passphrase** – tijagi Jul 20 '11 at 06:10
  • @user685107: whenever a ssh connection is asking for password, that means the pubilc key hasn't somehow been correctly published on the server side (in the ~/.ssh/authorized_keys files). Are you extra-sure the right public key is there? – VonC Jul 20 '11 at 06:14
  • Problem with windows users was solved by strictly following the manual of key generation with puttygen. And yes, I'm sure, cause public keys in /var/spool/gitosis/.ssh/authorized keys and in ~/.ssh/ match – tijagi Jul 21 '11 at 05:29
  • @user685107: "Problem with windows users was solved" ok but you still have an issue, I presume? – VonC Jul 21 '11 at 05:53
  • Now i have not, but windows users cannot pull or connect to gitosis. Trying to generate new key pairs, lol. – tijagi Jul 22 '11 at 12:55
  • @user685107: excellent. I have included your conclusions in the answer. – VonC Jul 25 '11 at 06:50
0

Setup git push with SSH

Generate SSH KEY with ssh-keygen

ssh-keygen -t rsa -C "your_github_email@example.com"

Github SSH connection setup

1. Copy the ssh from local machine

cat /home/ubuntu/.ssh/github_rsa.pub

2. Go to github account settings page

3. Click on New SSH Key

4. Add title and paste the copied ssh key from the local

5. Test SSH

ssh -T git@github.com

6. Update the Remote URL of the repository with the ssh url in place of https

  • Copy the ssh url from the repository

  • Copy clone with ssh URL - Clock Use SSH as in first screenshot

    git remote set-url origin git@github.com:JinnaBalu/GitCheatSheet.git

7. Test pushing with ssh

 git add --all

 git commit -am "testing the changes"

 git push -u origin master
Jinna Balu
  • 6,747
  • 38
  • 47