
따라서 다음과 같은 상황이 발생합니다. 각 프로젝트(예: )에 대한 전용 사용자가 있는 서버 foo
와 사용자로 실행되는 jenkins 서버입니다 jenkins
. 내 사용자를 위한 SSH 키 쌍을 생성 foo
하고 공개 키 쌍을 github 저장소에 배포 키로 추가했습니다. (사용자와 함께 저장소를 복제할 수 있음을 확인했습니다 foo
)
foo
Jenkins에서는 "Jenkins 관리" > "자격 증명 관리"에서 사용자 이름이 "foo"이고 의 개인 키가 "전역" 범위에 있는 "개인 키가 있는 SSH 사용자 이름"으로 인증을 설정했습니다 .
그래서 Jenkins 작업을 다음과 같이 구성했습니다.올바른 작업 공간(예: 분명히 /home/foo/deployment
사용자에 대한 완전한 소유권을 가짐 foo
) 그리고자격 증명 "foo" 사용. "소스 코드 관리"를 위해 내 저장소의 SSH URL을 사용하고 싶었습니다(예:[이메일 보호됨]:foo/foo.git) 그러나 권한 문제가 있음을 즉시 알려줍니다.
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h [email protected]:foo/foo.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
URL의 https 버전을 사용하는 경우(https://github.com/foo/foo.git) 오류는 사라지지만 작업을 실행하면 콘솔 출력에 다음 오류가 표시됩니다.
Started by user developer
[EnvInject] - Loading node environment variables.
Building in workspace /home/foo/deployment
Cloning the remote Git repository
Cloning repository https://github.com/foo/foo.git
> git init /home/foo/deployment # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init /home/foo/deployment
[long stacktrace]
Caused by: hudson.plugins.git.GitException: Command "git init /home/foo/deployment" returned status code 1:
stdout:
stderr: /home/foo/deployment/.git: Permission denied
[long stacktrace]
ERROR: null
Finished: FAILURE
키 쌍은 암호를 사용하지 않습니다. 하지만 이 암호가 먼저 작동하게 된다면 암호를 추가하고 싶습니다. Jenkins는 Ubuntu 14.04.2 LTS(GNU/Linux 3.13.0-65-generic x86_64) 상자에서 실행됩니다.
내가 여기서 무엇을 놓치고 있는 걸까요? 내가 제공한 자격 증명이 사용되지 않는 것 같습니다. 이는 권한이 폭증하는 이유를 설명합니다. 그런데 왜 사용되지 않는지 이해가 안 되나요? 그리고 왜 URL을 사용할 수 없나요 git@
?
권한 문제로 인해 막혔기 때문에 git init
에서 수동으로 실행했지만 /home/foo/deployment
Jenkins 작업을 다시 실행하면 git fetch
다시 권한 문제가 발생했습니다.
답변1
아 그래, 나 정말 바보같아. SSH 사용자 에이전트는 분명히 사용자가 jenkins
원격 저장소에 다음과 같이 연결할 수 있도록 허용 foo
하지만 로컬 파일 시스템에 쓸 수 있는 권한은 부여하지 않습니다.