Note
|
젠킨스가 설치되어 있는 서버를 클라이언트로 보고 이 클라이언트에서 ssh 공개키를 여러벌 만들고 사용하는 저장소에 등록한 후
ssh |
-
ssh key 생성
$ ssh-keygen -t rsa -f id_rsa_{repo_name_1} $ ssh-keygen -t rsa -f id_rsa_{repo_name_2} // ex [] ~ ssh-keygen -t rsa -f id_rsa_test // (1) Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_test. Your public key has been saved in id_rsa_test.pub. The key fingerprint is: SHA256:mTmXcyzRf9wX1MwxYEqZOHhsH0NkdfRDRCPJZqrCKqQ gimjiheon@gimjiheon-ui-MacBook-Pro.local The key's randomart image is: +---[RSA 2048]----+ | o +===*&o| | . *o*o== B| | o +.B o.| | + * . .+| | . S * o . =| | . o + + ..| | o . . | | E . . | | . | +----[SHA256]-----+ [] ~ ssh-keygen -t rsa -f id_rsa_test_2 // (2) Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_test_2. Your public key has been saved in id_rsa_test_2.pub. The key fingerprint is: SHA256:R3m/2/ayvMThpswtV9fnIVPpbqPhj8YIC0CgPnchyzA gimjiheon@gimjiheon-ui-MacBook-Pro.local The key's randomart image is: +---[RSA 2048]----+ | .. | | . . . | | E ... o . .| |. + o.. . . . o | | o + .. S . = .| | o . . o = ==| | . o o.Xo+| | . +oO=*o| | =*X*=| +----[SHA256]-----+
-
id_rsa_test
와id-id_rsa_test.pub
파일 생성 -
id_rsa_test_2
와id-id_rsa_test_2.pub
파일 생성id_rsa_test.pub
와id_rsa_test_2.pub
키를 각각 깃헙 저장소 deploy key 로 등록한다.
-
-
~/.ssh/config
파일 생성#test Host test HostName github.com User git IdentityFile ~/.ssh/id_rsa_test #test2 Host test2 HostName github.com User git IdentityFile ~/.ssh/id_rsa_test2
-
.
~/.ssh/config
파일이 정상적으로 되었는지 확인$ ssh git@test // (1) PTY allocation request failed on channel 0 Hi ihoneymon/test! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. $ ssh git@test2 // (2) PTY allocation request failed on channel 0 Hi ihoneymon/test2! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
-
id_rsa_test
를 이용해서 정상적으로 가져올 수 있는지 확인 -
id_rsa-test2
를 이용해서 정상적으로 가져올 수 있는지 확인
-
-
Jenkins Credential 에 생성한
id_rsa_test
,id_rsa_test2
에 대한 Credential 생성-
Kind: SSH Username with private key
-
Private Key - Enter directly
-
값은
cat id_rsa_test
를 통해 노출되는 값을 등록
-
-
-
Jenkins Item - 'Source Code management' 에서 Repository URL 변경
// 기존 git@github.com:ihoneymon/test // 변경 git@test:ihoneymon/test