git 为 Gerrit 和 Hudson 创建 SSH 密钥
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3712443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating SSH keys for Gerrit and Hudson
提问by Josh Smith
I'm trying to use the Hudson
Gerrit Trigger
plug-in.
我正在尝试使用Hudson
Gerrit Trigger
插件。
For whatever reason, Gerrit
is not accepting the SSH
key located at /var/lib/hudson/.ssh/id_rsa
.
无论出于何种原因,Gerrit
都不接受SSH
位于的密钥/var/lib/hudson/.ssh/id_rsa
。
In the GUII get Connection error : com.jcraft.jsch.JSchException: Auth fail
as an error, and when I'm working in the terminalI get a Permission denied (publickey)
error.
在 GUI 中我得到Connection error : com.jcraft.jsch.JSchException: Auth fail
一个错误,当我在终端中工作时我得到一个Permission denied (publickey)
错误。
How can I generate and use a working private key so Hudson
and Gerrit
can play nice?
我怎样才能生成和使用工作专用键,以便Hudson
和Gerrit
能发挥好?
回答by VonC
The OP Josh Smithmanaged to sort it out:
OP Josh Smith设法解决了这个问题:
I'd actually needed to add the
SSH
key from/var/lib/hudson/.ssh/id_rsa.pub
for the user (me) into the Gerrit GUI.
Then from there it worked like a charm.
The username must be the username in Gerrit (the admin account).
我实际上需要将用户(我)的
SSH
密钥添加/var/lib/hudson/.ssh/id_rsa.pub
到 Gerrit GUI 中。
然后从那里它就像一个魅力。
用户名必须是 Gerrit 中的用户名(管理员帐户)。
My original advice is below:
我的原始建议如下:
What is the user which will use the web based code review system Gerrit?
将使用基于 Web 的代码系统 Gerrit 的用户是什么?
That user needs your /var/lib/hudson/.ssh/id_rsa.pub
public ssh key in its $HOME/.ssh/authorized_keys
, as illustrated in this guide.
该用户需要您的/var/lib/hudson/.ssh/id_rsa.pub
公共 ssh 密钥$HOME/.ssh/authorized_keys
,如本指南中所示。
Key Distribution
密钥分发
The public portion of the RSA key pair must be copied to any servers that will be accessed by the client. The public key information to be copied should be located in the
~/.ssh/id_rsa.pub
file on the client.
Assuming that all of the servers use OpenSSH instead of a different SSH implementation, the public key data must be appended into the~/.ssh/authorized_keys
file on the servers.
必须将 RSA 密钥对的公共部分复制到客户端将访问的任何服务器。要复制的公钥信息应位于
~/.ssh/id_rsa.pub
客户端上的文件中。
假设所有服务器都使用 OpenSSH 而不是不同的 SSH 实现,则必须将公钥数据附加到~/.ssh/authorized_keys
服务器上的文件中。
# first, upload public key from client to server
client$ scp ~/.ssh/id_rsa.pub server.example.org:
# next, setup the public key on server
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
Be sure to append new public key data to the authorized_keys file, as multiple public keys may be in use. Each public key entry must be on a different line.
确保将新的公钥数据附加到authorized_keys 文件中,因为可能会使用多个公钥。每个公钥条目必须在不同的行上。