diff --git a/ci-setup-ssh.sh b/ci-setup-ssh.sh
index 3db642a11608d4059b58b89fed3073a0f4d75074..c644eb255dac5a5b8e77727dfea50026bf437a7e 100755
--- a/ci-setup-ssh.sh
+++ b/ci-setup-ssh.sh
@@ -6,7 +6,8 @@
 
 key_dir="${BUILD_DIR}/ssh"
 key_path="${key_dir}/vmkey"
-config_path="/root/.ssh/config"
+config_dir="/root/.ssh"
+config_path="${config_dir}/config"
 
 set -e
 
@@ -20,6 +21,8 @@ fi
 
 # Configure SSH to use it for the 10/8 network
 # (the network used by vmine).
+mkdir -p "${config_dir}"
+chmod 0700 "${config_dir}"
 cat >> "${config_path}" <<EOF
 Host 10.*
     User root