Skip to content

[Bug]: SSH agent forwarding doesn't work in some IDEs #749

@shdwchn10

Description

@shdwchn10

Before submitting

  • I have searched existing issues to confirm this is not a duplicate
  • I am running the latest version of DevPod

What happened?

DevPod forward SSH agent through different socket on each SSH session. But at least Zed and VSCodium with open-remote-ssh extension expect stable SSH agent socket. Because of that I'm unable to connect to SSH servers or authenticate against git forges from Zed or VSCodium.

Reference: loft-sh#1611

What did you expect to happen instead?

Be able to use SSH keys from ssh-agent inside DevPod in Zed and VSCodium.

Steps to reproduce

  1. Run devpod up .
  2. Open terminal inside Zed or VS Codium
  3.  [user@cf394da3fe79 teloxide]$ git pull
     sign_and_send_pubkey: signing failed for ED25519-SK "shdwchn10" from agent: agent refused operation
     sign_and_send_pubkey: signing failed for ED25519-SK "shdwchn10" from agent: agent refused operation
     git@github.com: Permission denied (publickey).
     fatal: Could not read from remote repository.
    
     Please make sure you have the correct access rights
     and the repository exists.
    
  4. $SSH_AUTH_SOCK is always stable. It doesn't change in freshly opened terminal from IDE.
    $ echo $SSH_AUTH_SOCK
    /tmp/auth-agent3542344653/listener.sock
    

devcontainer.json

{
    "build": {
        "dockerfile": "Containerfile"
    },
    "customizations": {
        "vscode": {
            "extensions": [
                "eamodio.gitlens",
                "rust-lang.rust-analyzer",
                "serayuzgur.crates",
                "tamasfe.even-better-toml",
                "nefrob.vscode-just-syntax",
                "Gruntfuggly.todo-tree"
            ]
        }
    },
    // ↓ Required for SELinux enabled systems
    "workspaceMount": "",
    "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
    "runArgs": [
        "--volume=${localWorkspaceFolder}:/workspaces/${localWorkspaceFolderBasename}:Z"
    ]
}

Error output / logs

How often does this happen?

Every time

Operating system

Linux

Linux distribution (if applicable)

Fedora Silverblue 43

Architecture

AMD64

Desktop app or CLI?

Both

DevPod version

v0.22.1

DevPod provider

Docker

Provider version

No response

Screenshots

No response

Anything else?

$SSH_AUTH_SOCK is always different between terminal sessions without IDE:

❯ ssh teloxide.devpod                                           
[user@cf394da3fe79 teloxide]$ echo $SSH_AUTH_SOCK 
/tmp/auth-agent2164616655/listener.sock
[user@cf394da3fe79 teloxide]$ 
logout
❯ ssh teloxide.devpod
[user@cf394da3fe79 teloxide]$ echo $SSH_AUTH_SOCK 
/tmp/auth-agent4248411302/listener.sock

Workaround

  1. Open terminal and write ssh <devpod_prj>.
  2. Get $SSH_AUTH_SOCK value: echo $SSH_AUTH_SOCK. Don't close terminal or ssh-agent forwarding will stop!
  3. Set it inside Zed/VS Codium terminal:
    [user@cf394da3fe79 teloxide]$ export SSH_AUTH_SOCK=/tmp/auth-agent3539020177/listener.sock
    [user@cf394da3fe79 teloxide]$ git pull
    Already up to date.
    
  4. This works for current IDE terminal though. It won't fix operations inside IDE, e.g. git: pull command in the Zed itself will still fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions