{"id":10613,"date":"2025-11-14T09:12:20","date_gmt":"2025-11-14T14:12:20","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=10613"},"modified":"2025-11-14T09:12:20","modified_gmt":"2025-11-14T14:12:20","slug":"adding-sshfs-mounted-shares-between-2-named-lan-clients-with-an-mdns-python-script","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/adding-sshfs-mounted-shares-between-2-named-lan-clients-with-an-mdns-python-script\/","title":{"rendered":"Adding SSHFS mounted shares between 2 NAMED LAN clients, with an mDNS python script"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10613\" class=\"pvc_stats all  \" data-element-id=\"10613\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>Install OpenSSH Server:<\/p>\n<p>Bash<\/p>\n<p>sudo apt update<br \/>\nsudo apt install openssh-server<br \/>\nConfigure SSHD: (Optional, but good for setup)<br \/>\nEdit \/etc\/ssh\/sshd_config (e.g., sudo nano \/etc\/ssh\/sshd_config):<\/p>\n<p>Ensure Port 22 is uncommented or set to your desired port.<\/p>\n<p>Ensure ListenAddress 0.0.0.0 to allow connections from any IP within WSL2's network (or even LAN if proxied).<\/p>\n<p>PasswordAuthentication yes (for initial testing, but consider SSH keys for long-term security).<\/p>\n<p>Subsystem sftp \/usr\/lib\/openssh\/sftp-server (this line should already be there).<br \/>\nSave changes and exit.<\/p>\n<p>Restart SSH service:<\/p>\n<p>Bash<\/p>\n<p>sudo service ssh restart<br \/>\nCrucially: Enable LAN access for PC_B's WSL2 on PC_B's Windows host.<br \/>\nThis is identical to the previous explanation for Windows Explorer access because the core problem is how to expose WSL2's internal IP to the LAN.<\/p>\n<p>Preferred (Windows 11 22H2+): Mirrored Mode Networking:<br \/>\nOn PC_B's Windows, edit C:\\Users\\YourWindowsUsername\\.wslconfig (create if doesn't exist):<\/p>\n<p>[wsl2]<br \/>\nnetworkingMode=mirrored<br \/>\nThen, in PowerShell on PC_B, wsl --shutdown and restart your WSL2 distro. This will give PC_B's WSL2 instance an IP directly on your LAN. Note down this IP address.<\/p>\n<p>Alternative (older Win11 or if mirrored mode issues): Port Forwarding:<br \/>\nOn PC_B's Windows, in an Administrator PowerShell, set up port forwarding from PC_B's LAN IP to PC_B's WSL2 internal IP (e.g., for port 22, or 2222 if you changed it). Remember to also open a firewall rule on PC_B's Windows for that port.<\/p>\n<p>Part 2: On PC_A (The Client WSL2 Instance)<br \/>\nThis is the WSL2 instance where you want to mount the remote files.<\/p>\n<p>Install SSHFS:<br \/>\nSSHFS relies on fuse (Filesystem in Userspace).<\/p>\n<p>Bash<\/p>\n<p>sudo apt update<br \/>\nsudo apt install sshfs<br \/>\nLoad FUSE module (usually automatic, but good to check):<\/p>\n<p>Bash<\/p>\n<p>sudo modprobe fuse<br \/>\n(You typically don't need to do this manually in WSL2 anymore as it usually loads on demand).<\/p>\n<p>Create a local mount point:<br \/>\nThis is where the remote files will appear.<\/p>\n<p>Bash<\/p>\n<p>mkdir -p remote_babyhp<br \/>\nMount the remote directory using SSHFS:<br \/>\nNow, from PC_A's WSL2 terminal, execute the sshfs command.<\/p>\n<p>Bash<\/p>\n<p>sshfs stevee@192.168.1.32:\/var\/www\/ remote_hplaptop -o allow_other<br \/>\nLet's break down this command:<\/p>\n<p>sshfs: The command to mount an SSH filesystem.<\/p>\n<p>your_username_on_pc_b: The username you use to log in to WSL2 on PC_B (e.g., stevee).<\/p>\n<p>PC_B_IP_ADDRESS:<\/p>\n<p>If using Mirrored Mode Networking on PC_B: This will be the actual LAN IP address of PC_B's WSL2 instance.<\/p>\n<p>If using Port Forwarding on PC_B: This will be the LAN IP address of PC_B's Windows host, not its WSL2 internal IP.<\/p>\n<p>:\/path\/to\/remote\/folder: This is the absolute path to the directory on PC_B's WSL2 instance that you want to mount (e.g., :\/home\/stevee\/my_project). The : separates the host\/user from the remote path.<\/p>\n<p>~\/remote_pc_b_files: The local mount point you created on PC_A.<\/p>\n<p>-o allow_other: This is important! By default, FUSE mounts are only accessible by the user who mounted them. allow_other makes the mounted filesystem accessible to other users (and processes) on PC_A's WSL2. This is often necessary for applications to interact with the mounted files.<\/p>\n<p>Example:<br \/>\nIf your user on PC_B is stevee, PC_B's WSL2 has the LAN IP 192.168.1.105 (via mirrored mode), and you want to mount \/var\/www from PC_B into ~\/hplaptop_www on PC_A:<\/p>\n<p>Bash<\/p>\n<p>sshfs stevee@babyhp:\/var\/www sshfs_babyhp<br \/>\nOR which PC you on:<br \/>\nsshfs stevee@hplaptop:\/var\/www sshfs_hplaptop<br \/>\nIt will then prompt you for the password for stevee on xx.<\/p>\n<p>To Unmount:<br \/>\nWhen you're done, unmount the directory:<\/p>\n<p>Bash<\/p>\n<p>sudo umount ~\/remote_pc_b_files<br \/>\nAdvantages of SSHFS for WSL2-to-WSL2:<br \/>\nSecurity: SSH provides a secure, encrypted tunnel for file transfer.<\/p>\n<p>No Samba Needed: You avoid the complexities of Samba configuration (smb.conf, smbpasswd, etc.) on the server side.<\/p>\n<p>Familiar Linux Tools: You're using native Linux commands (sshfs, mount, umount) directly within your WSL2 environments.<\/p>\n<p>Flexibility: You can mount specific directories rather than entire shares.<\/p>\n<p>This method is highly recommended for inter-WSL2 file access, offering a clean and secure solution.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_10613\" class=\"pvc_stats all  \" data-element-id=\"10613\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>Install OpenSSH Server: Bash sudo apt update sudo apt install openssh-server Configure SSHD: (Optional, but good for setup) Edit \/etc\/ssh\/sshd_config (e.g., sudo nano \/etc\/ssh\/sshd_config): Ensure Port 22 is uncommented or set to your desired port. Ensure ListenAddress 0.0.0.0 to allow connections from any IP within WSL2's network (or even LAN if proxied). PasswordAuthentication yes (for <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/adding-sshfs-mounted-shares-between-2-named-lan-clients-with-an-mdns-python-script\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 Adding SSHFS mounted shares between 2 NAMED LAN clients, with an mDNS python script<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10613","post","type-post","status-publish","format-standard","hentry","category-post"],"a3_pvc":{"activated":true,"total_views":1,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=10613"}],"version-history":[{"count":1,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10613\/revisions"}],"predecessor-version":[{"id":10614,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/10613\/revisions\/10614"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=10613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=10613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=10613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}