diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 18d8fb3c0c0b674bda251db63a7990b4b290012d..9f8ef2d23062dd1d4db56d8028efb06c32b19d42 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,14 +21,11 @@ deploy:
     GIT_REMOTE_URL: ssh://dokku@${APP_URL}:22/${APP_NAME}
     DOKKU_DEPLOY_BRANCH: dev
   before_script:
+    - eval $(ssh-agent -s)
+    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
     - mkdir -p ~/.ssh
     - chmod 700 ~/.ssh
-    - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
-    - chmod 600 ~/.ssh/id_rsa
-    - echo -e "Host ${APP_URL}\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile=/dev/null" > ~/.ssh/config
-    - chmod 600 ~/.ssh/config
   script:
-    - dokku-deploy || true
+    - dokku-deploy
   after_script:
-    - sleep 5
-    - ssh -i ~/.ssh/id_rsa -o ConnectTimeout=10 dokku@${APP_URL} apps:unlock ${APP_NAME} || true
\ No newline at end of file
+    - dokku-unlock
\ No newline at end of file