Report this

What is the reason for this report?

Gitlab Host key verification failed

Posted on May 31, 2016

I have a custom post-receive hook in Gitlab to SSH docker@example.com and run some SSH commands. But I’m still receiving this error:

michael@client ~/test $ git push -u origin master
Counting objects: 5, done.
Writing objects: 100% (3/3), 267 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Updating remote branch michael@docker.example.com /opt/test/master
remote: Host key verification failed.
To git@gitlab.example.com:michaelv1234/test.git
   6b276dc..89adda9  master -> master
Branch master set up to track remote branch master from origin.

Post-receive:

#!/bin/sh

read oldrev newrev refname

REPO="git@gitlab.example.com:michaelv1234/test.git"
BRANCH=`echo $refname | sed -n 's/^refs\/heads\///p'`
BRANCH_DIR="/opt/test"
SSH_DEST="michael@docker.example.com"

if [ "$newrev" -eq 0 ] 2> /dev/null; then
	# branch is being deleted
	echo "Deleting remote branch $SSH_DEST $BRANCH_DIR/$BRANCH"
	echo ssh $SSH_ARGS "$SSH_DEST" /bin/sh
	ssh $SSH_ARGS "$SSH_DEST" /bin/sh <<-EOF
		cd "$BRANCH_DIR" && rm -rf $BRANCH
	EOF
else
	# branch is being updated
	echo "Updating remote branch $SSH_DEST $BRANCH_DIR/$BRANCH"
	ssh $SSH_ARGS "$SSH_DEST" /bin/sh <<-EOF
		{ cd "$BRANCH_DIR/$BRANCH" || mkdir -p "$BRANCH_DIR/$BRANCH" && cd "$BRANCH_DIR/$BRANCH"; } \
		&& { git fetch origin && git reset --hard origin/$BRANCH || { git clone "$REPO" ./ && git checkout $BRANCH; }; }
	EOF
fi

The host key’s are not Changed

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.