You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker通过sshfs挂载远程卷失败求助:连接被对等方重置

Let's work through fixing that Connection reset by peer error you're hitting with the vieux/sshfs Docker plugin. I've tackled similar remote volume issues before, so here are the step-by-step checks and fixes to get your setup working:

1. First, Verify Basic SSH Connectivity (This is Make-or-Break)

The Docker plugin runs as the Docker daemon user (usually root), so you need to confirm this user can SSH into VM1 using your key without any prompts. On VM2:

  • Switch to the Docker daemon user (if you're not already logged in as root):
    su - root
    
  • Test the SSH connection directly:
    ssh -i /home/csicari/data/Mega/lavoro/keys/vm-csicari.key debian@vm1
    

If this fails, your plugin will never work. Common issues here:

  • Incorrect key permissions: SSH requires private keys to have 600 permissions, and the authorized_keys file on VM1 (in /home/debian/.ssh/) must also be 600, with the .ssh directory set to 700. Fix with:
    # On VM2, for your private key
    chmod 600 /home/csicari/data/Mega/lavoro/keys/vm-csicari.key
    # On VM1, for the authorized_keys file
    chmod 700 /home/debian/.ssh
    chmod 600 /home/debian/.ssh/authorized_keys
    
  • VM1 SSH restrictions: Check /etc/ssh/sshd_config on VM1 to ensure:
    • PasswordAuthentication isn't blocking key auth (it's okay if it's no, just make sure your key is in authorized_keys)
    • AllowUsers or AllowGroups isn't excluding the debian user
    • Port 22 is open in VM1's firewall/security group
  • SFTP is enabled: SSHFS relies on SFTP. Confirm Subsystem sftp /usr/lib/openssh/sftp-server is uncommented in /etc/ssh/sshd_config on VM1, then restart SSH:
    systemctl restart sshd
    
2. Fix Docker Plugin Access to Your SSH Key

The path you specified for IdentityFile is in the csicari user's home directory, which the Docker daemon (running as root) might not have permission to access. Here's how to fix this:

  • Copy the key to a location root can access, like /root/.ssh/:
    cp /home/csicari/data/Mega/lavoro/keys/vm-csicari.key /root/.ssh/
    chmod 600 /root/.ssh/vm-csicari.key
    
  • Delete the existing problematic volume and recreate it with the new key path:
    docker volume rm remotevolume
    docker volume create --name remotevolume -d vieux/sshfs \
      -o sshcmd=debian@vm1:/home/debian/sshfs300 \
      -o IdentityFile=/root/.ssh/vm-csicari.key \
      -o allow_other \
      -o nonempty
    
3. Validate the Target Directory on VM1

Double-check that the directory you're trying to mount exists and has the right permissions on VM1:

# On VM1
ls -ld /home/debian/sshfs300

Ensure the debian user has read/write access to this directory (the output should show rwx for the user). If not, fix permissions with:

chmod u+rwx /home/debian/sshfs300
4. Debug with Plugin Logs

Since you installed the plugin with DEBUG=1, you can get detailed logs to pinpoint the exact issue:

# On VM2
docker logs vieux/sshfs

This will show the full sshfs command the plugin is running, along with any error messages that might not show up in the Docker run error. Look for clues like "Permission denied" or "No such file or directory" for the key or target directory.

5. Test SSHFS Directly (Bypass Docker First)

To rule out Docker-specific issues, try mounting the remote directory directly on VM2 using sshfs:

mkdir -p /tmp/testmount
sshfs debian@vm1:/home/debian/sshfs300 /tmp/testmount \
  -o IdentityFile=/home/csicari/data/Mega/lavoro/keys/vm-csicari.key \
  -o allow_other \
  -o nonempty

If this works, the problem is definitely with the Docker plugin's configuration or permissions. If it fails, the error message will guide you to the root cause (e.g., network, key, or directory issues).

Once you've worked through these steps, try starting your container again with:

docker run -it -v remotevolume:/home -d ubuntu

内容的提问来源于stack exchange,提问作者Christian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 12:57:36