Jenkins 用户使用 apt-get install 安装
我刚刚通过 debian 安装步骤(使用 apt-get install)在我的 Ubuntu 服务器上安装了 Jenkins。我希望我的构建从 GitHub 上的私有 git 存储库中提取。这样,我需要使用 SSH 访问来访问我的存储库。
我的大多数搜索结果只是说以 Jenkins 用户身份登录并为我的 GitHub 帐户生成 SSH 密钥,但是通过 debian 包管理器安装,我没有 Jenkins 用户的密码。
那么如何生成 SSH 密钥供我的 Jenkins 服务器使用?
I just installed Jenkins on my Ubuntu server via the debian installation steps (using apt-get install). I want my build to pull from a private git repository on GitHub. With that, I need to use SSH access to get to my repository.
Most of my search results have just said to login as the Jenkins user and generate an SSH key for my GitHub account, but installing through the debian package manager, I don't have a password for the Jenkins user.
So how do I generate an SSH key for my Jenkins server to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我预计您有时会希望能够以 jenkins 身份登录来执行其他任务,因此我将解决更普遍的问题。最后包含对您的问题的严格回答。
在不知情的情况下更改 jenkins 的密码
从任何具有 sudo 权限,您可以将 jenkins 的密码重置为您选择的密码:
可能会首先要求您输入自己的密码,以便使用 sudo。然后系统将提示您为 jenkins 设置新密码,最后确认该新密码。
如果您拥有 sudo 权限的用户名为 joe,则会话可能如下所示:
替代方案:以 jenkins 身份登录,无需密码
或者,再次从合适的其他帐户使用 sudo,您可以以 jenkins 身份登录,而无需密码询问他的密码:
旁白:避免密码提示混淆
在发出
sudo passwd jenkins
之前,我们可能首先想使用 sudo 单独进行身份验证,以避免混淆问题“现在我被要求输入谁的密码?”。通过 sudo 成功进行身份验证后,有一个窗口(例如 15 分钟)不会提示我们再次进行身份验证。 (请注意,如果您想进行实验,可以使用
sudo -k
立即使该会话无效(终止)。)承诺的严格答案
然后使用 cat 查看内容要传递到 github 的公钥(但路径只是一个示例):
公钥文件的确切位置和名称取决于您在上面的 ssh-keygen 提示中输入的内容。我使用了詹金斯主目录的快捷方式,
~jenkins
。相关链接
I'll anticipate that from time to time you'll want to be able to log in as jenkins to do other tasks, and so I'll solve the more general problem. A strict answer to your question is included at the end.
Change jenkins' password without knowing it
From any account which has sudo permissions, you can reset jenkins' password to something of your choosing:
You may be asked first for your own password, in order to use sudo. Then you will be prompted for the new password to set for jenkins, and finally a confirmation of that new password.
If your user with sudo rights is called joe, here's how a session might look:
Alternative: login as jenkins without his password
Alternatively, again using sudo from a suitable other account, you can login as jenkins without being asked for his password:
An aside: Avoiding password prompt confusion
Before issuing
sudo passwd jenkins
, we might first like to authenticate separately with sudo to avoid confusion around the question "whose password am I being asked for, now?".After a successful authentication by sudo, there is a window (e.g. 15 minutes) where we won't be prompted to authenticate again. (Note that you can immediately invalidate (kill) this session with
sudo -k
, if you want to experiment.)The promised strict answer
Then use cat to view the contents of the public key to be passed to github (but the path is only an example):
The exact location and name of the public key file depends on what you entered to the prompts of ssh-keygen, above. I've used a shortcut to jenkins' home dir,
~jenkins
.Related Links