Page MenuHomePhabricator

Observing svn+ssh on non-standard ssh port
Closed, ResolvedPublic

Description

Trying to observe a SVN repo (using svn+ssh) on a remote server on a non-standard (not 22) ssh port.

Reproduction

  • You would have to have an external svn over ssh setup on a non-standard port (sorry, can't provide access to the one I'm using)
  • Following these steps here

e.g. for the URI (notice no mention of the port, port doesn't go in the URI, let's say it was configured for 1234 - important below):

svn+ssh://svn.host.name/srv/repo/url/path/
  • Activate the repository
  • Go to status, cloning/observing will fail due to invalid port

Version

Current Versions	
phabricator b26ecb189e486998acf469db0cba87993ef6ad1b (Mon, Jun 13) 
arcanist 7b0aac5c6f31c1374075b4eab20ecb9107e3cabd (Sat, Jun 11) 
phutil 0dca72380253edadcc0249dab82cb49d03672ccc (Thu, Jun 16)

Workaround

su <phabricator_user>
cd $HOME
vim $HOME/.ssh.config
---
Host svn.host.name
    Port 1234

That was the workaround I was most comfortable with. I could not get phabricator to use the $HOME/.subversion/config for tunnel settings (which is how this appears to normally be done). Also, setting the subversion config tunnel setting would impact _all_ repos where the .ssh/config method will be on a per-repo basis which is probably safer for configuration anyway...

Event Timeline

If you have time, can you let me know if this patch fixes things?

diff --git a/scripts/ssh/ssh-connect.php b/scripts/ssh/ssh-connect.php
index d42a542..8781cba 100755
--- a/scripts/ssh/ssh-connect.php
+++ b/scripts/ssh/ssh-connect.php
@@ -88,7 +88,22 @@ if ($as_device) {
   $arguments[] = AlmanacKeys::getKeyPath('device.key');
 }
 
+// Subversion passes us a host in the form "domaim.com:port", which is not
+// valid for normal SSH but which we can parse into a valid "-p" flag.
+
+$passthru_args = $unconsumed_argv;
+$host = array_shift($passthru_args);
+$parts = explode(':', $host, 2);
+$host = $parts[0];
+
 $port = $args->getArg('port');
+
+if (!$port) {
+  if (count($parts) == 2) {
+    $port = $parts[1];
+  }
+}
+
 if ($port) {
   $pattern[] = '-p %d';
   $arguments[] = $port;
@@ -96,7 +111,9 @@ if ($port) {
 
 $pattern[] = '--';
 
-$passthru_args = $unconsumed_argv;
+$pattern[] = '%s';
+$arguments[] = $host;
+
 foreach ($passthru_args as $passthru_arg) {
   $pattern[] = '%s';
   $arguments[] = $passthru_arg;

It appears to work locally, but I don't have a nonstandard-port remote SSH server to test on offhand.

I'm willing to give it a go, just to confirm before I do that what my URI would be in the UI?

svn+ssh://svn.host.name:port/srv/repo/url/path/

also, not in anyway a php/phab master but surprised to see this? though I didn't necessarily go about, in anyway, applying the patch yet so just noting it if worth attention from the diff

-$passthru_args = $unconsumed_argv;

Yes, put the port in the URI like a normal URI (host.com:1234).

That line moved up about 20 lines, and is now present under the comment near the top.

I've applied the patch and updated by URI accordingly (removed the ssh config as well) - seems to work

Thank you!