如何在通过ssh访问git repo (gitosis)时包含ssh私有rsa密钥



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

  1. 我可以克隆它,并通过ssh认证与私人和公共推keys(在gentoo上),但是使用Git Extensions的windows用户不会。放置在$HOME/中的SSH密钥。Ssh, Ssh要求输入密码。

  2. Redmine需要一个裸repo,所以我从我的gitosis克隆了一个repo并将其移动到服务器(redmine + git),然后尝试如图所示的同步http://www.redmine.org/projects/redmine/wiki/HowTo_keep_in_sync_your_git_repository_for_redmine但是它又要求输入密码了!我当然没有把阿帕奇变成他的自己的ssh密钥验证=_= (Apache是redmine bare的所有者repo,因为它通过http auth访问)

无论如何,问题是如何使用私人ssh密钥从文件时访问gitosis?

= = =

部分解决了!ssh-keygen -t rsa生成的密钥名称恰好是id_rsaid_rsa.pub。如果运行ssh -vvv gitosis@your-server.com,应该会看到类似

的内容
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

所以,ssh客户端需要准确命名的文件或将切换到下一个验证方法(密码)。现在我在我的家用机器上重命名keys和:

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

万岁,它要求一个密码短语!顺便说一句,ШIИDOШS™用户仍然有问题与他们的几十个生成的密钥。

乌利希期刊指南

如果使用OpenSSH,则在~/中。您可以创建一个名为"config"的文件,并在其中放入如下内容:

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

如果Windows用户定义了%HOME%环境变量,那么他们也应该能够(使用ssh)克隆。HOME默认没有定义。
它可以引用任何他们想要的目录(通常,一个与%HOMEPATH%相同)


OP user685107报告:

windows用户的问题通过严格遵循puttygen的密钥生成手册得到了解决。
在Windows中生成的新密钥对可以正常工作

使用SSH设置git push

使用SSH -keygen生成SSH KEY

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

Github SSH连接设置

1。从本地机器

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

2。转到github帐户设置页面

3。点击新建SSH密钥

4。添加标题并粘贴从本地

复制的ssh密钥

5。测试SSH

ssh -T git@github.com

6。用ssh URL代替https

更新存储库的远程URL
  • 从存储库复制ssh url

  • 使用ssh URL复制克隆-时钟使用ssh 在第一个截图

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

7。使用ssh

测试推送
 git add --all
 git commit -am "testing the changes"
 git push -u origin master

最新更新