summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Assistant/Pairing/MakeRemote.hs1
-rw-r--r--Assistant/Ssh.hs40
-rw-r--r--debian/changelog2
-rw-r--r--doc/bugs/can_not_add_ssh_remote_to_assistant_with___34__host:port__34___syntax.mdwn2
4 files changed, 32 insertions, 13 deletions
diff --git a/Assistant/Pairing/MakeRemote.hs b/Assistant/Pairing/MakeRemote.hs
index 38f9981e5..f938bac93 100644
--- a/Assistant/Pairing/MakeRemote.hs
+++ b/Assistant/Pairing/MakeRemote.hs
@@ -60,6 +60,7 @@ pairMsgToSshData msg = do
, sshUserName = Just (T.pack $ remoteUserName d)
, sshDirectory = T.pack dir
, sshRepoName = genSshRepoName hostname dir
+ , sshPort = 22
, needsPubKey = True
, rsyncOnly = False
}
diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs
index dad0a8415..c60ead1ef 100644
--- a/Assistant/Ssh.hs
+++ b/Assistant/Ssh.hs
@@ -24,6 +24,7 @@ data SshData = SshData
, sshUserName :: Maybe Text
, sshDirectory :: Text
, sshRepoName :: String
+ , sshPort :: Int
, needsPubKey :: Bool
, rsyncOnly :: Bool
}
@@ -188,7 +189,6 @@ genSshKeyPair = withTempDir "git-annex-keygen" $ \dir -> do
setupSshKeyPair :: SshKeyPair -> SshData -> IO SshData
setupSshKeyPair sshkeypair sshdata = do
sshdir <- sshDir
- let configfile = sshdir </> "config"
createDirectoryIfMissing True sshdir
unlessM (doesFileExist $ sshdir </> sshprivkeyfile) $ do
@@ -200,25 +200,39 @@ setupSshKeyPair sshkeypair sshdata = do
unlessM (doesFileExist $ sshdir </> sshpubkeyfile) $
writeFile (sshdir </> sshpubkeyfile) (sshPubKey sshkeypair)
+ setSshConfig sshdata
+ [ ("IdentityFile", "~/.ssh/" ++ sshprivkeyfile) ]
+ where
+ sshprivkeyfile = "key." ++ mangleSshHostName sshdata
+ sshpubkeyfile = sshprivkeyfile ++ ".pub"
+
+{- Setups up a ssh config with a mangled hostname.
+ - Returns a modified SshData containing the mangled hostname. -}
+setSshConfig :: SshData -> [(String, String)] -> IO SshData
+setSshConfig sshdata config = do
+ sshdir <- sshDir
+ createDirectoryIfMissing True sshdir
+ let configfile = sshdir </> "config"
unlessM (catchBoolIO $ isInfixOf mangledhost <$> readFile configfile) $
- appendFile configfile $ unlines
+ appendFile configfile $ unlines $
[ ""
, "# Added automatically by git-annex"
, "Host " ++ mangledhost
- , "\tHostname " ++ T.unpack (sshHostName sshdata)
- , "\tIdentityFile ~/.ssh/" ++ sshprivkeyfile
- ]
-
+ ] ++ map (\(k, v) -> "\t" ++ k ++ " " ++ v)
+ (settings ++ config)
return $ sshdata { sshHostName = T.pack mangledhost }
where
- sshprivkeyfile = "key." ++ mangledhost
- sshpubkeyfile = sshprivkeyfile ++ ".pub"
- mangledhost = mangleSshHostName
- (T.unpack $ sshHostName sshdata)
- (T.unpack <$> sshUserName sshdata)
+ mangledhost = mangleSshHostName sshdata
+ settings =
+ [ ("Hostname", T.unpack $ sshHostName sshdata)
+ , ("Port", show $ sshPort sshdata)
+ ]
-mangleSshHostName :: String -> Maybe String -> String
-mangleSshHostName host user = "git-annex-" ++ host ++ (maybe "-" ('-':) user)
+mangleSshHostName :: SshData -> String
+mangleSshHostName sshdata = "git-annex-" ++ host ++ (maybe "-" ('-':) user)
+ where
+ host = T.unpack $ sshHostName sshdata
+ user = T.unpack <$> sshUserName sshdata
unMangleSshHostName :: String -> String
unMangleSshHostName h
diff --git a/debian/changelog b/debian/changelog
index d41e9e88d..cbd8db184 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -26,6 +26,8 @@ git-annex (3.20121128) UNRELEASED; urgency=low
when preferred content settings want it.
* drop --auto: Fix dropping content when there are no preferred content
settings.
+ * webapp: Allow user to specify the port when setting up a ssh or rsync
+ remote.
-- Joey Hess <joeyh@debian.org> Wed, 28 Nov 2012 13:31:07 -0400
diff --git a/doc/bugs/can_not_add_ssh_remote_to_assistant_with___34__host:port__34___syntax.mdwn b/doc/bugs/can_not_add_ssh_remote_to_assistant_with___34__host:port__34___syntax.mdwn
index b1549dd41..dfe2738ef 100644
--- a/doc/bugs/can_not_add_ssh_remote_to_assistant_with___34__host:port__34___syntax.mdwn
+++ b/doc/bugs/can_not_add_ssh_remote_to_assistant_with___34__host:port__34___syntax.mdwn
@@ -26,3 +26,5 @@ this is not really a bug more of a wishlist feature.
[[!tag /design/assistant]]
+
+> Ok, it has a port field now. [[done]] --[[Joey]]