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

dvc add: "Invalid private key" when using agent and specifying key with public key #10690

Open
weberbr opened this issue Feb 18, 2025 · 1 comment
Assignees
Labels
fs: ssh Related to the SSH filesystem triage Needs to be triaged

Comments

@weberbr
Copy link

weberbr commented Feb 18, 2025

Bug Report

Description

I use an ssh agent with dozens of keys at a time. To avoid "Too many authentication failures" I must specify which private key my agent should use by adding an Identity File <path to corresponding public key> line to each of my hosts. Somewhere in the SSH stack that DVC uses (based on traceback info I'm guessing sshfs), this key loaded as a private key, which it of course fails the format checks on.

I took a look in the dvc_ssh client.py as well, and I'm not sure this case is handled properly there either.

Traceback I grabbed by setting logging output file: dvc_ssh_debug.log

Reproduce

  1. Generate an ssh keypair with ssh-keygen
  2. Install the public key to an authorized_keys file on a remote server with ssh-copy-id
  3. Install the private key to a local ssh-agent with ssh-add
  4. Edit your ~/.ssh/config to include:
Host <remote server>
    Hostname <remote hostname>
    IdentityFile <path to key>.pub
  1. In a new repo: dvc init
  2. dvc remote add remotessh ssh://<remote server>/<path>
  3. dvc add -r remotessh --to-remote mydata

Throws: ERROR: unexpected error - Invalid private key

Expected

dvc specifies to the agent which key to use using the provided public key

Environment information

Output of dvc doctor:

DVC version: 3.59.1 (pip)
-------------------------
Platform: Python 3.13.1 on Linux-6.8.0-52-generic-x86_64-with-glibc2.35
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: /home/myuser/.config/dvc
        System: /etc/xdg/dvc
Cache types: hardlink, symlink
Cache directory: ext4 on /dev/mapper/vgubuntu-root
Caches: local
Remotes: ssh, ssh
Workspace directory: ext4 on /dev/mapper/vgubuntu-root
Repo: dvc, git
Repo.site_cache_dir: /var/tmp/dvc/repo/6cf41b69515915320785cfda6839dd61

Additional Information (if any):

@shcheklein shcheklein added triage Needs to be triaged fs: ssh Related to the SSH filesystem labels Feb 18, 2025
@weberbr
Copy link
Author

weberbr commented Feb 18, 2025

It appears the issue is in either sshfs or asyncssh: I've filed another issue with sshfs here fsspec/sshfs#59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs: ssh Related to the SSH filesystem triage Needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants