如何通过ssh(gitosis)访问git repo时包含ssh private rsa key? [英] How to include ssh private rsa key when accessing git repo via ssh (gitosis)?

查看:177
本文介绍了如何通过ssh(gitosis)访问git repo时包含ssh private rsa key?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此时我已经通过gitosis添加了一个git repo。我使用的手册是 http: //scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way


  1. 我可以使用私有和公共
    键(在gentoo上)通过ssh auth克隆它,但是使用Git Extensions
    的windows用户不能。放置在$ HOME / .ssh中的SSH密钥以及ssh要求输入密码。
    也不是密码,也不是密码(来自专用ssh密钥)不匹配。
    Redmine需要一个裸回购,所以我克隆回购gitosis在我的
    本地机器上,并将其移动到服务器(redmine + git),然后试图
    同步就像这里显示
    http://www.redmine.org/projects/redmine/wiki/HowTo_keep_in_sync_your_git_repository_for_redmine
    但它要求重新输入密码!当然,我并没有将他的
    自己的ssh密钥作为apache来验证gitosis = _ =(Apache是​​redmine bare
    repo的拥有者,因此通过http auth访问它)


无论如何,问题是如何在访问gitosis时使用私钥ssh密钥?



===



部分解决!
ssh-keygen -t rsa 会生成密钥,其名称完全是 id_rsa id_rsa.pub
如果您运行 ssh -vvv gitosis@your-server.com 您应该看到类似于



  debug1:可继续的身份验证:publickey,键盘交互式
...
debug3:authmethod_is_enabled publickey
debug1:下一种身份验证方法:publickey
debug1:提供RSA公钥:user @ domain-user
debug3:send_pubkey_test $ b $ debug2:我们发送一个publickey包,等待回复
debug1:可以继续的验证:publickey,keyboard-interactive
debug1:尝试私钥:/home/user/.ssh/id_rsa
debug3:没有这样的标识:/home/user/.ssh/id_rsa
debug1:尝试私钥:/ home /user/.ssh/id_dsa
debug3:没有这样的标识:/home/user/.ssh/id_dsa
debug1:尝试私钥:/home/user/.ssh/id_ecdsa
debug3 :没有这样的标识:/home/user/.ssh/id_ecdsa
debug2:我们没有发送数据包,禁用方法
debug3:authmethod_lookup键盘交互

所以,ssh客户端需要完全命名的文件或将切换到下一个身份验证方法(密码)。现在我在家用机器上重新命名了键:

  user @ home〜$ git clone ssh:// git @ your-gitosis -server / reponame.git 
克隆到reponame ...
输入密钥'/home/user/.ssh/id_rsa'的密码:

华友世纪,它要求一个密码!顺便说一句,ШIИDOśS™用户仍然有数十个生成的按键问题。



更新



如果你使用OpenSSH,那么在〜/ .ssh中你可以创建一个名为'config'的文件并在其中放置如下内容:

  Host mygitosisserver.com 
IdentityFile〜/ .ssh / private-key-for-mygitosisserver-com


如果用户定义了%HOME%环境变量,那么Windows用户应该能够克隆(使用ssh),

解决方案


HOME未被默认定义。

它可以引用他们想要的任何目录(通常,一个比%HOMEPATH%






OP user685107 报告:


严格按照puttygen的密钥生成手册解决了windows用户的问题。

新钥匙在Windows中配对工作正常



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

解决方案

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

这篇关于如何通过ssh(gitosis)访问git repo时包含ssh private rsa key?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆