背景
項目中使用jenkins自動獲取git代碼并發(fā)版韧掩,都是通過execute shell方式记某,沒有使用jenkins的Source Code Management。公司組織架構調整后,所有git的root賬號被新技術總監(jiān)收回虎锚,導致發(fā)版錯誤围详,顯示:
GitLab: Your account has been blocked.
fatal: The remote end hung up unexpectedly
修復
1.申請新git賬號
看提示應該是root賬號改了密碼或者是原發(fā)版賬號被blocked朴乖。申請新git賬號后把原jenkins服務器的公鑰(通過cat /root/.ssh/id_rsa.pub 查看)配置到新git賬號中,但是提示添加錯誤:
The form contains the following error:
* Fingerprint has already been taken
原因是公鑰配置在了其他賬號中助赞,只支持配置一次买羞,所以需要新生成公鑰配置在該賬號中。
2.jenkins服務器生成新公鑰
到jenkins服務器中雹食,執(zhí)行生成新公鑰的命令并查看:
ssh-keygen -C 'youraccount@example.com' -t rsa
cat /root/.ssh/id_rsa.pub
將新生成的公鑰配置到git中(如果沒有配置到git中畜普,會報以下錯誤,因為 git clone失斎阂丁):
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: The remote end hung up unexpectedly
git添加新公鑰成功后吃挑,在Your SSH keys里會出現新公鑰信息
3.SIT發(fā)版
SIT環(huán)境和Jenkins在一個服務器中,從git拷貝代碼成功了并且發(fā)版成功街立。
4.UAT發(fā)版
UAT環(huán)境和Jenkins不在同一個服務器中舶衬,發(fā)版時報錯:
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied, please try again.
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
lost connection
查了一下jenkins配置,使用jenkins的Execute sshell sript on remote host using ssh赎离,遠程連接到UAT服務器發(fā)版
5.ssh免密登陸其他服務器
因為Jenkins公鑰重新生成了约炎,所以保留在UAT服務器中的密鑰也需要修改,拷貝新生成的公鑰信息到UAT服務器
cd /root/.ssh
vim authorized_keys
清除原來的公鑰拷貝新公鑰,然后再次發(fā)版,成功圾浅。
6. 總結
主要問題有兩個掠手,一個是無密訪問git,一個是無密訪問其他服務器狸捕。修改git賬號后都重新配置就好了喷鸽。