summaryrefslogtreecommitdiff
path: root/Ssh.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-03-05 15:47:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-03-05 15:47:00 -0400
commit6c1607ce66fb456880495d9026fa368ad48eda3e (patch)
tree85a35c24aa718b90a9c11b6d59686d9a0acd7103 /Ssh.hs
parentaad1372880ba32f1161a0d05422008cba38bb412 (diff)
Support ssh remotes with a port specified.
Diffstat (limited to 'Ssh.hs')
-rw-r--r--Ssh.hs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Ssh.hs b/Ssh.hs
new file mode 100644
index 000000000..04cd9bec8
--- /dev/null
+++ b/Ssh.hs
@@ -0,0 +1,26 @@
+{- git-annex repository access with ssh
+ -
+ - Copyright 2011 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+module Ssh where
+
+import qualified Annex
+import qualified GitRepo as Git
+import Utility
+import Types
+
+{- 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 <- Annex.repoConfig repo "ssh-options" ""
+ let sshoptions = map Param (words s)
+ let sshport = case Git.urlPort repo of
+ Nothing -> []
+ Just p -> [Param "-p", Param (show p)]
+ let sshhost = Param $ Git.urlHostUser repo
+ return $ sshoptions ++ sshport ++ [sshhost] ++ sshcmd