ssh connection caching

Ssh connection caching is now enabled automatically by git-annex. Only one
ssh connection is made to each host per git-annex run, which can speed some
things up a lot, as well as avoiding repeated password prompts. Concurrent
git-annex processes also share ssh connections. Cached ssh connections are
shut down when git-annex exits.

Note: The rsync special remote does not yet participate in the ssh
connection caching.
This commit is contained in:
Joey Hess 2012-01-20 15:34:52 -04:00
parent 25f998679c
commit 47250a153a
9 changed files with 173 additions and 23 deletions

View file

@ -7,25 +7,21 @@
module Remote.Helper.Ssh where
import Common
import Common.Annex
import qualified Git
import qualified Git.Url
import Types
import Config
import Annex.UUID
import Annex.Ssh
{- Generates parameters to ssh to a repository's host and run a command.
- Caller is responsible for doing any neccessary shellEscaping of the
- passed command. -}
sshToRepo :: Git.Repo -> [CommandParam] -> Annex [CommandParam]
sshToRepo repo sshcmd = do
s <- getConfig repo "ssh-options" ""
let sshoptions = map Param (words s)
let sshport = case Git.Url.port repo of
Nothing -> []
Just p -> [Param "-p", Param (show p)]
let sshhost = Param $ Git.Url.hostuser repo
return $ sshoptions ++ sshport ++ [sshhost] ++ sshcmd
opts <- map Param . words <$> getConfig repo "ssh-options" ""
params <- sshParams (Git.Url.hostuser repo, Git.Url.port repo)
return $ opts ++ params ++ sshcmd
{- Generates parameters to run a git-annex-shell command on a remote
- repository. -}