remote_access.sh: Unset SSH_AUTH_SOCK unless --ssh_allow_agent

It turns out that using SSH_AUTH_SOCK can make ssh connections super
slow to establish in some situations.  Let's remove it unless the user
specifically requests it.

This speeds update_kernel up from ~35 seconds to ~5 seconds on most
Google Engineer's workstations.

BUG=None
TEST=time ./update_kernel.sh --remote=zzz --noreboot --ssh_allow_agent
TEST=time ./update_kernel.sh --remote=zzz --noreboot

Change-Id: I696e1b318c5864c3d2307cef7517b884d04e145b
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410243
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/remote_access.sh b/remote_access.sh
index 4b0202a..fcbc601 100644
--- a/remote_access.sh
+++ b/remote_access.sh
@@ -16,6 +16,7 @@
   "SSH connect timeout in seconds"
 DEFINE_integer ssh_connection_attempts 4 \
   "SSH connection attempts"
+DEFINE_boolean ssh_allow_agent ${FLAGS_FALSE} "Don't block out SSH_AUTH_SOCK"
 
 # Returns true if $1 has at least two colons.
 has_two_colons_or_more() {
@@ -246,5 +247,12 @@
     echo "Please specify --remote=<IP-or-hostname> of the Chromium OS instance"
     exit 1
   fi
+
+  # Having SSH_AUTH_SOCK set makes our ssh connections super slow so unset
+  # if it's not really needed.
+  if [[ ${FLAGS_ssh_allow_agent} -eq ${FLAGS_FALSE} ]]; then
+    unset SSH_AUTH_SOCK
+  fi
+
   set_up_remote_access
 }