diff --git a/dvc/fs/ssh.py b/dvc/fs/ssh.py index 9966d147c..b2e4cc7fe 100644 --- a/dvc/fs/ssh.py +++ b/dvc/fs/ssh.py @@ -39,7 +39,7 @@ class SSHFileSystem(FSSpecWrapper): path_str = path.path else: path_str = super()._with_bucket(path) - return os.path.normpath(path_str) + return path_str def _prepare_credentials(self, **config): self.CAN_TRAVERSE = True diff --git a/tests/unit/fs/test_ssh.py b/tests/unit/fs/test_ssh.py index 60712e9b1..cac9d6732 100644 --- a/tests/unit/fs/test_ssh.py +++ b/tests/unit/fs/test_ssh.py @@ -178,3 +178,23 @@ def test_ssh_multi_identity_files(mock_file): def test_ssh_gss_auth(mock_file, config, expected_gss_auth): fs = SSHFileSystem(**config) assert fs.fs_args["gss_auth"] == expected_gss_auth + + +@pytest.mark.parametrize( + "url, path", + [ + ("ssh://a@b/", "/"), + ("ssh://a@b:/", "/"), + ("ssh://a@b/home", "/home"), + ("ssh://a@b:/home", "/home"), + ("ssh://a@b/home/tmp", "/home/tmp"), + ("ssh://a@b:/home/tmp", "/home/tmp"), + ("ssh://a@b/home/tmp/something", "/home/tmp/something"), + ("ssh://a@b:/home/tmp/something", "/home/tmp/something"), + ], +) +def test_ssh_fs_path_management(url, path): + fs = SSHFileSystem(host="x.y.z") + + path_info = fs.PATH_CLS(url) + assert fs._with_bucket(path_info) == path