Jenkins 用户使用 apt-get install 安装

发布于 2024-11-11 18:04:50 字数 265 浏览 3 评论 0原文

我刚刚通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱要勇敢去追 2024-11-18 18:04:50

我预计您有时会希望能够以 jenkins 身份登录来执行其他任务,因此我将解决更普遍的问题。最后包含对您的问题的严格回答。

在不知情的情况下更改 jenkins 的密码

从任何具有 sudo 权限,您可以将 jenkins 的密码重置为您选择的密码:

sudo passwd jenkins

可能会首先要求您输入自己的密码,以便使用 sudo。然后系统将提示您为 jenkins 设置新密码,最后确认该新密码。

如果您拥有 sudo 权限的用户名为 joe,则会话可能如下所示:

joe $ sudo passwd jenkins
[sudo] password for joe:     **you enter joe's passwd**
Enter new UNIX password:     ** you enter new jenkins passwd**
Retype new UNIX password:    ** you enter new jenkins passwd**
passwd: password updated successfully

替代方案:以 jenkins 身份登录,无需密码

或者,再次从合适的其他帐户使用 sudo,您可以以 jenkins 身份登录,而无需密码询问他的密码:

sudo su - jenkins

旁白:避免密码提示混淆

在发出 sudo passwd jenkins 之前,我们可能首先想使用 sudo 单独进行身份验证,以避免混淆问题“现在我被要求输入谁的密码?”。

sudo -v
sudo passwd jenkins

通过 sudo 成功进行身份验证后,有一个窗口(例如 15 分钟)不会提示我们再次进行身份验证。 (请注意,如果您想进行实验,可以使用 sudo -k 立即使该会话无效(终止)。)

承诺的严格答案

sudo -u jenkins ssh-keygen

然后使用 cat 查看内容要传递到 github 的公钥(但路径只是一个示例):

  sudo cat ~jenkins/.ssh/id_rsa.pub

公钥文件的确切位置和名称取决于您在上面的 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:

sudo passwd jenkins

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:

joe $ sudo passwd jenkins
[sudo] password for joe:     **you enter joe's passwd**
Enter new UNIX password:     ** you enter new jenkins passwd**
Retype new UNIX password:    ** you enter new jenkins passwd**
passwd: password updated successfully

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:

sudo su - jenkins

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?".

sudo -v
sudo passwd jenkins

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

sudo -u jenkins ssh-keygen

Then use cat to view the contents of the public key to be passed to github (but the path is only an example):

  sudo cat ~jenkins/.ssh/id_rsa.pub

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文