Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
martijnwgnr opened this issue Feb 6, 2025 · 5 comments · Fixed by #105
Closed

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

martijnwgnr opened this issue Feb 6, 2025 · 5 comments · Fixed by #105

Comments

@martijnwgnr
Copy link

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
@skshetry
Copy link
Member

skshetry commented Feb 6, 2025

@martijnwgnr, do you have any Port set in ~/.ssh/config? asyncssh should already be using the default port if not set.

@martijnwgnr
Copy link
Author

@skshetry No, I have not changed anything (the file does not even exist actually)

@skshetry
Copy link
Member

skshetry commented Feb 6, 2025

I now see the bug, I'll create a patch quickly. :)

@skshetry
Copy link
Member

skshetry commented Feb 6, 2025

Can you PTAL at #105 and see if it fixes the issue?

You can install as follows:

pip install "dvc-ssh @ git+https://github.com/iterative/dvc-ssh.git@fix-unstrip-protocol"

@martijnwgnr
Copy link
Author

Works perfectly, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants