diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e5ec93327266540d4cb98acbee6a3a1f5d000039..199bb0cd54c4143327682db4c79206c7a57ee317 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,15 +18,14 @@ before_script:
   ## without extra base64 encoding.
   ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
   ##
+  - mkdir -p ~/.ssh
+  - chmod 700 ~/.ssh  
   - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
+  - echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts
 
   ##
   ## Create the SSH directory and give it the right permissions
   ##
-  - mkdir -p ~/.ssh
-  - chmod 700 ~/.ssh  
-  - ssh-keyscan -H gitlab.iri.upc.edu >> $HOME/.ssh/known_hosts
-  
   - ls
   - apt-get update
   - apt-get install -y build-essential cmake