Skip to content

[Idea] Remote version in your todo list #70

@draftman9

Description

@draftman9

1. Best Option: Reverse SSH Tunneling + mount --bind (on the Linux server)

This is the most flexible and secure method, and it avoids installing extra server software on the Linux machine if you already have SSH access. It's also the closest to the concept of "mounting" the local directory on the remote, although it involves a clever trick.

  • How it works:

    1. You create a reverse SSH tunnel from your Windows machine to the Linux server. This tunnel forwards a port on the Linux server back to your Windows machine.
    2. On the Windows machine, you run a simple file-sharing service (like Samba's smbd in a minimal configuration, or even a simple Python HTTP server) that shares the local directory you want to mount. This service listens on the port that's being forwarded by the SSH tunnel.
    3. On the Linux server, you use mount --bind (or mount a CIFS/SMB share if you used Samba on Windows) to mount the shared directory (which is accessible via the forwarded port) to the desired location on the Linux filesystem.
  • Pros:

    • Secure: Uses SSH for the connection, so it's encrypted.
    • No extra server software (usually): Only requires SSH on the Linux server (which you likely already have). You might need a simple file-sharing service on Windows, but often a very minimal one will do.
    • Relatively straightforward: Once you understand the concept, the steps are not too complex.
    • Full control: You have complete control over the shared directory on your Windows machine.
    • Mount on demand: You can connect the tunnel only when you need access to the local folder.
  • Cons:

    • Requires understanding of SSH tunneling: This is the main hurdle; you need to be comfortable with the concept of reverse SSH tunnels.
    • Requires a file-sharing service on Windows: You need something to share the local directory, even if it's very basic.
    • Performance can be limited: There is overhead related to tunnel and file-sharing server, so it is slower than local file access.
  • Example (Conceptual - needs adapting to your specifics):

    1. On Windows (Command Prompt):

      • Install a simple file-sharing solution. One very easy option is Python's built-in HTTP server (if you have Python installed):

        cd /d/e/daemon  REM Change to your local directory
        python -m http.server 8080

        This makes the D:\e\daemon directory available over HTTP on port 8080. This is not secure for production use, but it's perfect for a temporary, tunneled connection. For a more robust solution, use a minimal Samba configuration (see later examples). Crucially, this server must be running before you establish the SSH tunnel.

      • Create the reverse SSH tunnel:

        ssh -R 12345:localhost:8080 quantum4@183.169.63.12 -p 10916
        • -R 12345:localhost:8080: This is the reverse tunnel definition.
          • 12345: The port on the remote Linux server that will be forwarded. Choose a high, unused port number.
          • localhost:8080: The address and port on your Windows machine that the traffic will be forwarded to. localhost refers to your Windows machine, and 8080 is the port where the Python HTTP server (or your chosen file-sharing service) is listening.
        • quantum4@183.169.63.12 -p 10916: Your standard SSH connection details.
          This command opens an SSH session to your server, and keeps the tunnel open as long as the session is active. You'll have a shell on the remote server. Keep this window open!
    2. On Linux Server (in the SSH session you just opened):

      sudo mkdir /mnt/windows_share  # Or wherever you want to mount it
      sudo mount -t cifs -o port=12345,username=guest,password=,vers=3.0 //localhost/ /mnt/windows_share
      • We have to use cifs, because even built-in python http server serves files over SMB protocol.
      • //localhost/: Because we're accessing the forwarded port on the local machine (the Linux server), we use localhost. The trailing / is important.
      • -o port=12345: Specifies the forwarded port on the Linux server.
      • -o username=guest,password=: This works for the simple Python HTTP server, as it doesn't require authentication. If you use Samba, you'll need to provide appropriate credentials here.
      • vers=3.0: Explicitly use SMB version 3.0 for better security and compatibility. Older versions are vulnerable.
      • /mnt/windows_share: The location on the Linux filesystem where you want to mount the Windows directory.

      Alternatively, if you are fine with read-only access, you can use the following to bind the share

      sudo mkdir /mnt/windows_share
      sudo mount --bind /proc/self/fd/$(python3 -c "import socket; s=socket.socket(); s.connect(('localhost', 12345)); print(s.fileno())") /mnt/windows_share
      • This slightly more complicated command uses mount --bind to connect directly to the open socket provided by the SSH tunnel.
      • The advantage is that it is cleaner (no need to create fake SMB connection).
      • The disadvantage is that it only works for read-only access.
    3. Unmounting

      • On Linux Server
        sudo umount /mnt/windows_share
      • Close SSH session.

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