[英]load key : permission denied jenkins
I am trying to run a multibranch job in jenkins .我正在尝试在 jenkins 中运行多分支工作。 Codes are placed in git.
代码放在 git 中。 While running the job I am getting access rights issue.
在运行作业时,我遇到了访问权限问题。 While generating the
ssh-keygen
in jenkins getting the permission denied error.在 jenkins 中生成
ssh-keygen
时出现权限被拒绝错误。
Configuring in ubuntu box.在 ubuntu 框中配置。
git ls-remote -h git@github.com:****/*****1.git HEAD
The authenticity of host 'github.com ("IP Address")' can't be established.
RSA key fingerprint is SHA256:********************Y8.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/var/lib/jenkins/.ssh/known_hosts).
Load key "/var/lib/jenkins/.ssh/id_rsa": Permission denied
Permission denied (publickey).
fatal: Could not read from remote repository.
Load key "/var/lib/jenkins/.ssh/id_rsa": Permission denied
is about reading the local private ssh key on your local file system, and has nothing to do with the remote server. Load key "/var/lib/jenkins/.ssh/id_rsa": Permission denied
是关于读取本地文件系统上的本地私有 ssh 密钥,与远程服务器无关。
Make sure that you have read permission for your ssh key.确保您对 ssh 密钥具有读取权限。 (I experienced this issue when my key was encrypted by my Windows host, but my Docker container couldn't decrypt it.)
(当我的密钥被 Windows 主机加密时,我遇到了这个问题,但我的 Docker 容器无法解密它。)
You could also always just generate a new key and try that one.您也可以始终只生成一个新密钥并尝试使用该密钥。
This error is coming because you might have copied the id_rsa file into the location /var/lib/jenkins/.ssh/
.出现此错误是因为您可能已将 id_rsa 文件复制到
/var/lib/jenkins/.ssh/
位置。 You might have copied the file either from local machine to the remove server or created the keys at root level.您可能已将文件从本地计算机复制到删除服务器或在根级别创建了密钥。 So file "id_rsa" have owner as root and you are trying to access this file from your jenkins.
因此,文件“id_rsa”的所有者为 root,您正尝试从 jenkins 访问此文件。 Jenkins should be the owner to read the file.
Jenkins 应该是读取文件的所有者。 Below are the steps to check and fix this issue
以下是检查和解决此问题的步骤
sudo su
and then go inside /var/lib/jenkins/.ssh/
. sudo su
然后进入/var/lib/jenkins/.ssh/
。ls -la
ls -la
-r--------. 1 root root 18 Sep 1 10:00 id_rsa
-r--------. 1 root root 18 Sep 1 10:00 id_rsa
-r--------. 1 root root 18 Sep 1 10:00 id_rsa
chown jenkins:jenkins id_rsa
.chown jenkins:jenkins id_rsa
。 This command will change owner of the file from root to jenkins.-r--------. 1 jenkins jenkins 18 Sep 1 10:01 id_rsa
-r--------. 1 jenkins jenkins 18 Sep 1 10:01 id_rsa
-r--------. 1 jenkins jenkins 18 Sep 1 10:01 id_rsa
chmod 400 id_rsa
chmod 400 id_rsa
I have solved the issue by following above steps.我已经按照上述步骤解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.