[배포] Jenkins private Github 저장소 SSH 에러 (status code 208)

layl__a·2023년 4월 21일
0

Jenkins

목록 보기
3/4

Jenkins 와 Github 연결해서 webhook으로 배포를 시도하고 있었는데 credentialsId 와 SSH 키를 설정해도 아래와 같은 문제가 발생했다.

Started by user hmgadmin
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/HMG_1
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Tool Install)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Prepare)
[Pipeline] tool
[Pipeline] envVarsForTool
[Pipeline] withEnv
[Pipeline] {
[Pipeline] git
The recommended git tool is: NONE
using credential (크레덴셜 아이디)
 > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/HMG_1/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url 
 (SSH git 주소)
 # timeout=10
Fetching upstream changes from 
(SSH git 주소)
 > git --version # timeout=10
 > git --version # 'git version 2.30.2'
using GIT_SSH to set credentials 
Verifying host key using known hosts file
You're using 'Known hosts file' strategy to verify ssh host keys, but your known_hosts file does not exist, please go to 'Manage Jenkins' -> 'Configure Global Security' -> 'Git Host Key Verification Configuration' and configure host key verification.
 > git fetch --tags --force --progress -- 
 (SSH git 주소) +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from
(SSH git 주소)
hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1003)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1309)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:97)
	at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:84)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- 
(SSH git 주소)
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: No ECDSA host key is known for github.com and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2732)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2109)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:623)
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
	... 11 more
Post stage
[Pipeline] sh
+ echo Fail Cloned Repository
Fail Cloned Repository
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build Gradle Test)
Stage "Build Gradle Test" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Docker rm)
Stage "Docker rm" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Bulid Gradle)
Stage "Bulid Gradle" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Bulid Docker)
Stage "Bulid Docker" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Docker Run)
Stage "Docker Run" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE

여기서 중요한 부분이 아래의 로그인 것 같은데, 호스트 키를 인식하지 못하는 문제인 것 같다.

stderr: No ECDSA host key is known for github.com and you have requested strict checking.
Host key verification failed.

구글링을 해본 결과,
https://stackoverflow.com/questions/15174194/jenkins-host-key-verification-failed

known_hosts에 등록되지 않았다고 한다.

jenkins@ea1f0b09c539:~$ git ls-remote -h (SSH github 주소) HEAD
The authenticity of host 'github.com (20.200.245.247)' can't be established.
ECDSA key fingerprint is SHA256:-/-/-.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,20.200.245.247' (ECDSA) to the list of known hosts.

위와 같은 명령어를 수행하니, 새로운 HOST에 SSH를 통해 접속할 때 발생하는 경고 메시지가 나왔고, YES를 클릭했더니 이 문제는 해결되었다.
known_hosts에 github에 추가해준 것으로 해결 된 것이다.


결과적으로 github 저장소를 가져오는 건 됐지만...

이번에는 Build Gradle 에서 문제가 난다..!
installReact 문제인데, 다시 천천히 고쳐보겠다...

0개의 댓글