Skip to content

Default ssh port is not selected when using dvc from command line #104

Closed
@martijnwgnr

Description

@martijnwgnr

Executing dvc pull from the command line results in a KeyError. This seems to be introduced by commit e452803, which removes the default port. The issue only seems to arise when no port is specified when defining a remote:

['remote "share"']
    url = ssh://[email protected]/data/dvc/

Adding the default ssh port to the url fixes the issue:

['remote "share"']
    url = ssh://[email protected]:22/data/dvc/

The full error/traceback:

dvc pull -v
...
2025-02-06 10:04:42,914 ERROR: unexpected error - 'port'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/dvc/cli/__init__.py", line 211, in main
    ret = cmd.do_run()
  File "/usr/local/lib/python3.10/site-packages/dvc/cli/command.py", line 27, in do_run
    return self.run()
  File "/usr/local/lib/python3.10/site-packages/dvc/commands/data_sync.py", line 35, in run
    stats = self.repo.pull(
  File "/usr/local/lib/python3.10/site-packages/dvc/repo/__init__.py", line 58, in wrapper
    return f(repo, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/dvc/repo/pull.py", line 30, in pull
    processed_files_count = self.fetch(
  File "/usr/local/lib/python3.10/site-packages/dvc/repo/__init__.py", line 58, in wrapper
    return f(repo, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/dvc/repo/fetch.py", line 184, in fetch
    fetch_transferred, fetch_failed = ifetch(
  File "/usr/local/lib/python3.10/site-packages/dvc_data/index/fetch.py", line 128, in fetch
    with closing(get_index(data.odb)) as src_index:
  File "/usr/local/lib/python3.10/site-packages/dvc_data/hashfile/db/__init__.py", line 46, in get_index
    hashlib.sha256(odb.fs.unstrip_protocol(odb.path).encode("utf-8")).hexdigest(),
  File "/usr/local/lib/python3.10/site-packages/dvc_ssh/__init__.py", line 44, in unstrip_protocol
    port = self.fs_args["port"]
KeyError: 'port'
2025-02-06 10:04:42,930 DEBUG: Version info for developers:
DVC version: 3.59.0 (pip)
-------------------------
Platform: Python 3.10.12 on Linux-5.4.0-174-generic-x86_64-with-glibc2.28
Subprojects:
	dvc_data = 3.16.9
	dvc_objects = 5.1.0
	dvc_render = 1.0.2
	dvc_task = 0.40.2
	scmrepo = 3.3.10
Supports:
	http (aiohttp = 3.11.12, aiohttp-retry = 2.9.1),
	https (aiohttp = 3.11.12, aiohttp-retry = 2.9.1),
	ssh (sshfs = 2025.2.0)
Config:
	Global: /root/.config/dvc
	System: /etc/xdg/dvc
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: ssh
Workspace directory: ext4 on /dev/md2
Repo: dvc, git

Dependencies of interest:

dvc==3.59.0
dvc-data==3.16.9
dvc-http==2.32.0
dvc-objects==5.1.0
dvc-render==1.0.2
dvc-ssh==4.2.0
dvc-studio-client==0.21.0
dvc-task==0.40.2
asyncssh==2.19.0
sshfs==2025.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions