remote_access.sh: Use opportunistic, automatic ControlMaster

Change remote_access to automatically attempt to share a single SSH
connection.  This significantly speeds up remote_access since we avoid
all of the connection establishment the majority of the time.

This shaves a few seconds off of update_kernel.

BUG=None
TEST=Try updating a kernel

Change-Id: I33f0cd856c9e15d25adb4c28389d833596798cb4
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410244
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/remote_access.sh b/remote_access.sh
index fcbc601..cbe011a 100644
--- a/remote_access.sh
+++ b/remote_access.sh
@@ -52,6 +52,9 @@
       "IdentitiesOnly=yes"
       "IdentityFile=${TMP_PRIVATE_KEY}"
       "UserKnownHostsFile=${TMP_KNOWN_HOSTS}"
+      "ControlPath=${TMP_CONTROL_FILE}"
+      "ControlMaster=auto"
+      "ControlPersist=45"
     )
     printf -- '-o %s ' "${settings[@]}"
   fi
@@ -243,6 +246,8 @@
 remote_access_init() {
   TMP_PRIVATE_KEY=$TMP/private_key
   TMP_KNOWN_HOSTS=$TMP/known_hosts
+  TMP_CONTROL_FILE="${TMP}/ssh_control%r@%h:%p"
+
   if [ -z "$FLAGS_remote" ]; then
     echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance"
     exit 1