aboutsummaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-10-26 16:41:34 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-10-26 16:41:34 -0400
commite356796fc7ee493ff6b6a7e9cbcbc2971ab23729 (patch)
treee65a038719daea8c871a435cb0d03ddcbd482783 /Annex
parentd3c4be40c05e107b39b08a918dfb3ec991444d6e (diff)
Run ssh with ServerAliveInterval 60
So that stalled transfers will be noticed within about 3 minutes, even if TCPKeepAlive is disabled or doesn't work. Rather than setting with -o, use -F with another config file, so that any settings in ~/.ssh/config or /etc/ssh/ssh_config overrides this.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Locations.hs5
-rw-r--r--Annex/Ssh.hs35
2 files changed, 33 insertions, 7 deletions
diff --git a/Annex/Locations.hs b/Annex/Locations.hs
index a6af4d417..9f829fda1 100644
--- a/Annex/Locations.hs
+++ b/Annex/Locations.hs
@@ -63,6 +63,7 @@ module Annex.Locations (
gitAnnexUrlFile,
gitAnnexTmpCfgFile,
gitAnnexSshDir,
+ gitAnnexSshConfig,
gitAnnexRemotesDir,
gitAnnexAssistantDefaultDir,
HashLevels(..),
@@ -402,6 +403,10 @@ gitAnnexTmpCfgFile r = gitAnnexDir r </> "config.tmp"
gitAnnexSshDir :: Git.Repo -> FilePath
gitAnnexSshDir r = addTrailingPathSeparator $ gitAnnexDir r </> "ssh"
+{- .git/annex/ssh.config is used to configure ssh. -}
+gitAnnexSshConfig :: Git.Repo -> FilePath
+gitAnnexSshConfig r = gitAnnexDir r </> "ssh.config"
+
{- .git/annex/remotes/ is used for remote-specific state. -}
gitAnnexRemotesDir :: Git.Repo -> FilePath
gitAnnexRemotesDir r = addTrailingPathSeparator $ gitAnnexDir r </> "remotes"
diff --git a/Annex/Ssh.hs b/Annex/Ssh.hs
index 4f879436b..43c2c13a9 100644
--- a/Annex/Ssh.hs
+++ b/Annex/Ssh.hs
@@ -33,6 +33,7 @@ import qualified Git.Url
import Config
import Annex.Path
import Utility.Env
+import Utility.Tmp
import Types.CleanupActions
import Git.Env
#ifndef mingw32_HOST_OS
@@ -49,13 +50,33 @@ sshOptions (host, port) gc opts = go =<< sshCachingInfo (host, port)
go (Just socketfile, params) = do
prepSocket socketfile
ret params
- ret ps = return $ concat
- [ ps
- , map Param (remoteAnnexSshOptions gc)
- , opts
- , portParams port
- , [Param "-T"]
- ]
+ ret ps = do
+ overideconfigfile <- fromRepo gitAnnexSshConfig
+ -- We assume that the file content does not change.
+ -- If it did, a more expensive test would be needed.
+ liftIO $ unlessM (doesFileExist overideconfigfile) $
+ viaTmp writeFile overideconfigfile $ unlines
+ -- ssh expands "~"
+ [ "Include ~/.ssh/config"
+ -- ssh will silently skip the file
+ -- if it does not exist
+ , "Include /etc/ssh/ssh_config"
+ -- Everything below this point is only
+ -- used if there's no setting for it in
+ -- the above files.
+ --
+ -- Make sure that ssh detects stalled
+ -- connections.
+ , "ServerAliveInterval 60"
+ ]
+ return $ concat
+ [ ps
+ , [Param "-F", File overideconfigfile]
+ , map Param (remoteAnnexSshOptions gc)
+ , opts
+ , portParams port
+ , [Param "-T"]
+ ]
{- Returns a filename to use for a ssh connection caching socket, and
- parameters to enable ssh connection caching. -}