I had an unusual issue on my pipeline a few days ago, and I observed a bizarre error log that didn't mean anything to me:
Connection closed by UNKNOWN port 65535
I discovered that the pipeline has stuck at Kex Algorithm:
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug3: receive packet: type 96 debug2: channel 0: rcvd eof debug2: channel 0: output open -> drain debug2: channel 0: obuf empty debug2: chan_shutdown_write: channel 0: (i0 o1 sock -1 wfd 5 efd -1 [closed]) debug2: channel 0: output drain -> closed debug1: channel 0: FORCE input drain debug2: channel 0: ibuf empty debug2: channel 0: send eof debug3: send packet: type 96 debug2: channel 0: input drain -> closed Connection closed by UNKNOWN port 65535
I found the solution after several headache-inducing searches🎉.
KexAlgorithms curve25519-sha256,ecdh-sha2-nistp521 below
Host * on both Jumpbox and Destination Server, I ran the pipeline again but guess what? it failed!
When I saw the
connection time out! I realized that the same thing had occurred in the pipeline, and the Kex Algorithm needs to be configured on both servers and the pipeline.
I edited my
.gitlab-ci.yml file and added the line
- sed -i -e "s/Host \*/&\nKexAlgorithms curve25519-sha256,ecdh-sha2-nistp521/g" before anything with SSH:
before_script: - apk add openssh-client rsync - sed -i -e "s/Host \*/&\nKexAlgorithms curve25519-sha256,ecdh-sha2-nistp521/g" /etc/ssh/ssh_config
sed -i -e "s/Host \*/&\nKexAlgorithms curve25519-sha256,ecdh-sha2-nistp521/g" /etc/ssh/ssh_config I add Kex Algorithms to the ssh_config file and tried again.
This time, the pipeline functioned well, and our application was successfully deployed to the destination server.
You can see the detailed article in my blog on Hashnode: