diff --git a/src/Handler.php b/src/Handler.php
index 054d631e6fbe06156715d23a13d60c07ffc94f1b..f963d55c49f1743ae7a0a4a2f109346c429f1f09 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -295,7 +295,9 @@ class Handler extends BaseHandler {
       $ssh_auth_sock = getenv('SSH_AUTH_SOCK');
       $options['php']['ssh'] = !empty($ssh_auth_sock);
       if ($options['php']['ssh']) {
-        $options['php']['ssh_auth_sock'] = $this->getDockerMountSource('/ssh-agent');
+        $options['php']['ssh_auth_sock'] = ($this->isCiContext() || $this->isLocalDevMode()) ?
+          $this->getDockerMountSource('/ssh-agent') :
+          '$SSH_AUTH_SOCK';
       }
 
       $options['projectroot'] = $projectRoot;