zoukankan      html  css  js  c++  java
  • Jenkins连接Git仓库时候报错Permission denied, please try again.

    一、连接GIT仓库报错

    Failed to connect to repository : Command "git ls-remote -h git@192.168.5.71:/home/git/www.git HEAD" returned status code 128:
    stdout:
    stderr: Permission denied, please try again.
    Permission denied, please try again.
    Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.

     二、问题原因

    我是通过yum安装的Jenkins,安装过程中创建了jenkins用户,并作为service以这个用户来运行。所以无论是root还是当前用户的ssh key都是不生效的。

    # ps aux | grep jenkins
    jenkins   2528 13.4 15.2 3665292 591388 ?      Ssl  Nov18 155:31 /etc/alternatives/java -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20

    三、解决方法

    最简单的方法是把服务用户由jenkins修改为root

    # sed -n '29p' /etc/sysconfig/jenkins 
    JENKINS_USER="root"
    # systemctl restart jenkins.service 
    # ps aux | grep jenkins
    root     19132  169  5.8 3563124 225760 ?      Ssl  09:59   0:06 /etc/alternatives/java -Dcom.sun.akuma.Daemon=daemonized -Djava.awt.headless=true -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --daemon --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20

    另一种就是为jenkins这个用户再生成ssh key,然后设置到git系统

  • 相关阅读:
    C# Renci.SshNet SFTP--FTP 操作help
    点评js异步加载的4种方式
    C# csv 操作类
    Redis分布式缓存
    webApi FileReader
    Web API 2 authentication with JWT
    Web SQL
    jQuery图像照片剪裁插件Jcrop中文演示
    使用ajax跨域withCredentials的作用
    JavaScript 判断浏览器类型及版本
  • 原文地址:https://www.cnblogs.com/cyleon/p/11887412.html
Copyright © 2011-2022 走看看