Repository: iterative/dvc

Issue:
unexpected error import-url with ssh
## Bug Report
Hello,
I was trying to import some data, that have been tracked by dvc, from my server with ssh and got the following error.
I got the data by scp just to be sure if everything is working and it is.
 
### Please provide information about your setup
both server and local on ubuntu 18.04 with DVC 1.7.8 on server and DVC 1.7.4 local

**Output of `dvc version`:1.7.8

```console

(base) gabriel@gabriel:~/Documents/test/t3$ dvc import-url ssh://glnotebook@xxx:/home/data/teste/data/data.xml -v
2020-09-24 19:08:47,161 DEBUG: Check for update is enabled.
2020-09-24 19:08:47,165 DEBUG: fetched: [(3,)]                        
2020-09-24 19:08:47,543 DEBUG: Removing output 'data.xml' of stage: 'data.xml.dvc'.
Importing 'ssh://glnotebook@xxx:/home/data/teste/data/data.xml' -> 'data.xml'
2020-09-24 19:08:47,544 DEBUG: Computed stage: 'data.xml.dvc' md5: 'f0ed66031e9686d7284fc6f25bd395da'
2020-09-24 19:08:47,544 DEBUG: 'md5' of stage: 'data.xml.dvc' changed.
2020-09-24 19:08:47,545 DEBUG: Establishing ssh connection with 'xxx' through port '22' as user 'glnotebook'
2020-09-24 19:08:51,365 DEBUG: Downloading 'ssh://glnotebook@xxx/home/data/teste/data/data.xml' to 'data.xml'
2020-09-24 19:08:51,367 DEBUG: fetched: [(0,)]
2020-09-24 19:08:51,371 ERROR: unexpected error
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/main.py", line 76, in main
    ret = cmd.run()
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/command/imp_url.py", line 18, in run
    no_exec=self.args.no_exec,
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/repo/__init__.py", line 51, in wrapper
    return f(repo, *args, **kwargs)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/repo/scm_context.py", line 4, in run
    result = method(repo, *args, **kw)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/repo/imp_url.py", line 54, in imp_url
    stage.run()
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/funcy/decorators.py", line 39, in wrapper
    return deco(call, *dargs, **dkwargs)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/stage/decorators.py", line 36, in rwlocked
    return call()
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/funcy/decorators.py", line 60, in __call__
    return self._func(*self._args, **self._kwargs)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/stage/__init__.py", line 429, in run
    sync_import(self, dry, force)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/stage/imports.py", line 30, in sync_import
    stage.deps[0].download(stage.outs[0])
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/output/base.py", line 320, in download
    self.tree.download(self.path_info, to.path_info)
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/tree/base.py", line 381, in download
    from_info, to_info, name, no_progress_bar, file_mode, dir_mode
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/tree/base.py", line 439, in _download_file
    from_info, tmp_file, name=name, no_progress_bar=no_progress_bar
  File "/home/gabriel/anaconda3/lib/python3.7/site-packages/dvc/tree/ssh/__init__.py", line 249, in _download
    assert from_info.isin(self.path_info)
AssertionError
```


Discussion:
Discord context https://discordapp.com/channels/485586884165107732/485596304961962003/758812810032578593
For the record, a less anonymised url looks like `ssh://user@1.2.3.4/home/data/teste/data/data.xml`

Resolving patch:
diff --git a/dvc/tree/ssh/__init__.py b/dvc/tree/ssh/__init__.py
--- a/dvc/tree/ssh/__init__.py
+++ b/dvc/tree/ssh/__init__.py
@@ -246,8 +246,7 @@ def getsize(self, path_info):
             return ssh.getsize(path_info.path)
 
     def _download(self, from_info, to_file, name=None, no_progress_bar=False):
-        assert from_info.isin(self.path_info)
-        with self.ssh(self.path_info) as ssh:
+        with self.ssh(from_info) as ssh:
             ssh.download(
                 from_info.path,
                 to_file,
@@ -256,8 +255,7 @@ def _download(self, from_info, to_file, name=None, no_progress_bar=False):
             )
 
     def _upload(self, from_file, to_info, name=None, no_progress_bar=False):
-        assert to_info.isin(self.path_info)
-        with self.ssh(self.path_info) as ssh:
+        with self.ssh(to_info) as ssh:
             ssh.upload(
                 from_file,
                 to_info.path,


Test patch: