jenkins 配置git 提示“无法连接仓库:Command “git ls-remote -h -- gitxxxxxxxxx status code 128”
jenkins 配置git 提示“无法连接仓库
无法连接仓库:Command “git ls-remote -h – git@codeup.aliyun.com:xxxxxxxxxxxxxxx/xxxxxx.git HEAD” returned status code 128:
stdout:
stderr: Load key “/tmp/jenkins-gitclient-ssh14549883685367104196.key”: error in libcrypto
git@codeup.aliyun.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
![(https://img-blog.csdnimg.cn/direct/a6d0f353eef34591b673d3dfd9dd5c14.png)
1.先切换到jenkins用户下(此时在jenkins安装目录下)
注意:这里我的jenkins启动用户是jenkins,如果是root则在root用户下生成密钥。那个用户启动用哪个用户生成!
sudo su -s /bin/bash jenkins
cd ~
2.生成新的ssh秘钥(生成PEM格式的私钥与公钥)
ssh-keygen -m PEM -t rsa -f id_rsa
# ssh-keygen -t rsa(这个不行)
3.复制生成的公钥到gitlab
cat .ssh/id_rsa.pub
或者
cat id_rsa.pub
复制私钥必须全部字符内容
实际应该将ssh-keygen生成的id_rsa文件中的全部内容粘贴到Jenkins的凭据private key那里,同时要包含首行与尾行。
执行一下这个
git ls-remote -h -- git@codeup.aliyun.com:64fxxxxxxxxxxxxxxx_demo.git HEAD
最后保存在配置就可以了
控制台提示文件或文件夹无权限(这个好像不太行)
如:
cp: cannot create regular file '/date/jenkins-publish.tar': Permission denied
修改jenkins的配置问卷,我使用的是Ubuntu的apt包管理器安装的在 /etc/default/jenkins
vim /etc/default/jenkins
# defaults for Jenkins automation server
# pulled in from the init script; makes things easier.
#NAME=jenkins 这个是默认的用户
NAME=root # 这个是修改为执行用户为root
# arguments to pass to java
# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="-Djava.awt.headless=true"
#JAVA_ARGS="-Xmx256m"
# make jenkins listen on IPv4 address
#JAVA_ARGS="-Djava.net.preferIPv4Stack=true"
PIDFILE=/var/run/$NAME/$NAME.pid
# user and group to be invoked as (default to jenkins)
JENKINS_USER=$NAME
JENKINS_GROUP=$NAME
# location of the jenkins war file
JENKINS_WAR=/usr/share/java/$NAME.war
之后重启jenkins就可以了
这个可以
给jenkins添加对应文件夹的权限
chown -R jenkins /data