Git SSH 认证 [英] Git SSH authentication

查看:26
本文介绍了Git SSH 认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器上有 Debian、Fisheye 和 Git.我的 git 存储库由 Fisheye 管理.鱼眼部分没有身份验证.所有的认证过程都由git管理.

I have Debian, Fisheye and Git on my server. My git repos are managed by Fisheye. There is no authentication at the Fisheye part. All authentication procedures are managed by git.

我想使用 SSH 身份验证,以便在将更改推送到服务器时不需要提供用户名和密码.我知道如何创建 rsa 密钥,但是我应该在服务器上的哪里复制我的公钥?

I would like to use SSH authentication, so that I do not need to provide username and password as I push my changes to the server. I know how to create an rsa key, but where do I copy my public key at the server?

推荐答案

文章的关键部分服务器上的 Git - 设置服务器" 是:

The key part of the article "Git on the Server - Setting Up the Server" is:

您需要向该用户的 ~/.ssh/authorized_keys 文件中添加一些开发人员 SSH 公钥.
假设您通过电子邮件收到了一些密钥并将它们保存到临时文件中.同样,公钥看起来像这样:

you need to add some developer SSH public keys to the ~/.ssh/authorized_keys file for that user.
Let’s assume you’ve received a few keys by e-mail and saved them to temporary files. Again, the public keys look something like this:

$ cat /tmp/id_rsa.john.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCB007n/ww+ouN4gSLKssMxXnBOvf9LGt4L
ojG6rs6hPB09j9R/T17/x4lhJA0F3FR1rP6kYBRsWj2aThGw6HXLm9/5zytK6Ztg3RPKK+4k
Yjh6541NYsnEAZuXz0jTTyAUfrtU3Z5E003C4oxOj6H0rfIF1kKI9MAQLMdpGW1GYEIgS9Ez
Sdfd8AcCIicTDWbqLAcU4UpkaX8KyGlLwsNuuGztobF8m72ALC/nLF6JLtPofwFBlgc+myiv
O7TCUSBdLQlgMVOFq1I2uPWQOkOWQAHukEOmfjy2jctxSDBQ220ymjaNsHT4kgtZg2AYYgPq
dAv8JggJICUvax2T9va5 gsg-keypair

(注意:确保键显示在一行)

(Note: make sure the key is displayed on one single line)

您只需将它们附加到您的 authorized_keys 文件中:

You just append them to your authorized_keys file:

$ cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keys

如果您的服务器上没有 authorized_keys 文件,请创建它,但请确保正确保护它.

If you don't have an authorized_keys file on your server, create it, but make sure to protect it correctly.

server$ mkdir ~/.ssh
server$ chmod 700 ~/.ssh
server$ cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
server$ chmod 600 ~/.ssh/authorized_keys
server$ rm ~/id_rsa.pub

有关具体示例,请参阅为 Gerrit 和 Hudson 创建 SSH 密钥".

See "Creating SSH keys for Gerrit and Hudson" for a concrete example.

  • 确保 git 在您的 ssh 守护程序使用的 PATH 中.
  • 确保您的 ~/.ssh 的所有父目录都不可写入组(仅限 chmod 755).
  • Make sure git is in the PATH used by your ssh daemon.
  • Make sure all parent directories of your ~/.ssh are not writable for the group (chmod 755 only).

这篇关于Git SSH 认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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