Solved Mounting a disk on FreeBSD shared in Windows by installing SFTP/OpenSSH/SSHFS

Hello.

I'm trying to mount a disk on FreeBSD shared in Windows by installing SFTP/OpenSSH/SSHFS. Below you can see what I did right now :

on Windows 11 :

followed this tutorial : https://winscp.net/eng/docs/guide_windows_openssh_server#fn2

1) Downloaded the latest OpenSSH for Windows from here :


2) As the Administrator, extracted the package to C:\Program Files\OpenSSH
3) As the Administrator, installed sshd and ssh-agent services with this command :

Code:
powershell.exe -ExecutionPolicy Bypass -File install-sshd.ps1

4) As the Administrator, ran the following PowerShell command :

Code:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\Program Files\OpenSSH\ssh.exe"

Name                          : sshd
DisplayName                   : OpenSSH SSH Server
Description                   :
DisplayGroup                  :
Group                         :
Enabled                       : True
Profile                       : Any
Platform                      : {}
Direction                     : Inbound
Action                        : Allow
EdgeTraversalPolicy           : Block
LooseSourceMapping            : False
LocalOnlyMapping              : False
Owner                         :
PrimaryStatus                 : OK
Status                        : The rule was parsed successfully from the store. (65536)
EnforcementStatus             : NotApplicable
PolicyStoreSource             : PersistentStore
PolicyStoreSourceType         : Local
RemoteDynamicKeywordAddresses : {}

5)

Code:
C:\ProgramData\ssh\sshd_config :


PermitRootLogin yes

#AllowAgentForwarding yes

AllowTcpForwarding remote

#GatewayPorts no

#PermitTTY yes

#PrintMotd yes

#PrintLastLog yes

#TCPKeepAlive yes

#UseLogin no

#PermitUserEnvironment no

#ClientAliveInterval 0

#ClientAliveCountMax 3

#UseDNS no

#PidFile /var/run/sshd.pid

#MaxStartups 10:30:100

PermitTunnel yes

#ChrootDirectory none

#VersionAddendum none

#PasswordAuthentication yes

#PermitEmptyPasswords no

6) Before the first connection,found out the fingerprint of the server’s host key by using ssh-keygen.exe for each file. In Windows command-prompt, used :

Code:
λ for %f in (%ProgramData%\ssh\ssh_host_*_key) do c:\"program files"\OpenSSH\ssh-keygen.exe -l -f "%f"


c:\"program files"\OpenSSH\ssh-keygen.exe -l -f "C:\ProgramData\ssh\ssh_host_dsa_key"

1024 SHA256: authority\system@marietto-windows11 (DSA)


c:\"program files"\OpenSSH\ssh-keygen.exe -l -f "C:\ProgramData\ssh\ssh_host_ecdsa_key"

256 SHA256: authority\system@marietto-windows11 (ECDSA)


c:\"program files"\OpenSSH\ssh-keygen.exe -l -f "C:\ProgramData\ssh\ssh_host_ed25519_key"

256 SHA256: authority\system@marietto-windows11 (ED25519)


c:\"program files"\OpenSSH\ssh-keygen.exe -l -f "C:\ProgramData\ssh\ssh_host_rsa_key"

3072 SHA256: authority\system@marietto-windows11 (RSA)

7)

Code:
C:\ProgramData\ssh

λ ipconfig


Windows IP Configuration



Ethernet adapter Ethernet 4:


   Connection-specific DNS Suffix  . : homenet.telecomitalia.it

   IPv4 Address. . . . . . . . . . . : 192.168.1.6

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Default Gateway . . . . . . . . . : 192.168.1.1



λ ping 192.168.1.6


Pinging 192.168.1.6 with 32 bytes of data:

Reply from 192.168.1.6: bytes=32 time<1ms TTL=128

Reply from 192.168.1.6: bytes=32 time<1ms TTL=128


SERVICE_NAME: ssh-agent

DISPLAY_NAME: OpenSSH Authentication Agent

        TYPE               : 10  WIN32_OWN_PROCESS

        STATE              : 4  RUNNING

                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)

        WIN32_EXIT_CODE    : 0  (0x0)

        SERVICE_EXIT_CODE  : 0  (0x0)

        CHECKPOINT         : 0x0

        WAIT_HINT          : 0x0

        PID                : 8788

        FLAGS              :


SERVICE_NAME: sshd

DISPLAY_NAME: OpenSSH SSH Server

        TYPE               : 10  WIN32_OWN_PROCESS

        STATE              : 4  RUNNING

                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)

        WIN32_EXIT_CODE    : 0  (0x0)

        SERVICE_EXIT_CODE  : 0  (0x0)

        CHECKPOINT         : 0x0

        WAIT_HINT          : 0x0

        PID                : 11176

        FLAGS              :

8) According with this tutorial : https://github.com/winfsp/sshfs-win

a) Installed the latest version of WinFsp.
b) Installed the latest version of SSHFS-Win.
c) Installed the latest version of SSHFS-Win Manager.
d) With SSHFS-Win Manager mounted the SSHFS drive G: mapped as drive : drive_g (J)


On FreeBSD :


Code:
/etc/rc.conf :

hostname="marietto"

ifconfig_em0="DHCP"

local_unbound_enable="YES"

sshd_enable="YES"

gateway_enable="YES"

kld_list="fusefs"

cloned_interfaces="bridge0 tap0 eth0 lo1"

ifconfig_bridge0="addm em0 addm tap0"


/usr/home/marietto/Desktop # ping 192.168.1.6


PING 192.168.1.6 (192.168.1.6): 56 data bytes

64 bytes from 192.168.1.6: icmp_seq=0 ttl=128 time=0.222 ms

64 bytes from 192.168.1.6: icmp_seq=1 ttl=128 time=1.230 ms

64 bytes from 192.168.1.6: icmp_seq=2 ttl=128 time=0.224 ms


This is the error I get :


# sshfs -o allow_other -o sshfs_debug marietto@192.168.1.6:/drive_g /mnt/sshfs
SSHFS version 3.7.2
ssh: connect to host 192.168.1.6 port 22: operation timed out
remote host has disconnected

But in Windows it works great. Please give a look at the screenshots that I have attached. If it works on Windows,it should work also in FreeBSD. So,I suppose the error is on the FreeBSD configuration.
 

Attachments

  • Screenshot_2022-04-30_21-33-10.jpg
    Screenshot_2022-04-30_21-33-10.jpg
    53.3 KB · Views: 62
  • Screenshot_2022-04-30_21-34-06.jpg
    Screenshot_2022-04-30_21-34-06.jpg
    28.1 KB · Views: 71
  • Screenshot_2022-04-30_21-35-10.jpg
    Screenshot_2022-04-30_21-35-10.jpg
    32.9 KB · Views: 78
  • Screenshot_2022-04-30_21-35-37.jpg
    Screenshot_2022-04-30_21-35-37.jpg
    26.4 KB · Views: 62
  • Screenshot_2022-04-30_21-37-47.jpg
    Screenshot_2022-04-30_21-37-47.jpg
    37.8 KB · Views: 62
I don't know what the problem is but i can give a good advice nevertheless:
You post way too much useless information which makes it hard to spot where the problem is.
Maybe try to reduce the post to a necessary minimum.

Volume is not precision
 
It is not possible because I don't know with the utmost precision what informations are relevant and what aren't.
 
Does the directory /mnt/sshts exist on the FreeBSD system before you try mounting something to it???
 
yes,I've created that folder before to give this command :

# sshfs -o allow_other -o sshfs_debug marietto@192.168.1.6:/drive_g /mnt/sshfs

but after having issued that command,this is what happens when I tried to see what's the content inside it :

Code:
marietto:/usr/home/marietto # ls /mnt/sshfs
ls: /mnt/sshfs: Device not configured
 
Solution found thanks to the help of @rykolepl on Reddit. He suggested that the cause was the windows firewall and he was right.
I've turned it down and it worked.

Code:
/usr/local/bin/sshfs marietto@192.168.1.6:/G:/ "/mnt/sshfs"
marietto@192.168.1.6's password:

root@marietto:/usr/home/marietto # ls /mnt/sshfs

file1 file2 file3

now,the last step : I don't want to turn off the Windows firewall. Is there a way to baypass the firewall keeping it turned on ?
 
maybe open the ssh port?

I've thought that this was the command line to open the ssh port. And yes,I've opened it just before to post the question :

Code:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\Program Files\OpenSSH\ssh.exe"
 
This method stopped working and I don't understand where is the error (Windows firewall is down) :

Screenshot_2022-06-26_18-00-55.jpg

Screenshot_2022-06-26_17-43-34.jpg
 
Have you upgraded one of the "sides" (either client or server)? Specifically, ssh. Sometimes, newer versions of ssh brings changes in defaults, like which ciphers are supported, which ciphers are working as defaults and so on.
an easy way to check if this is the problem is to just ssh from the client to the server. If you can ssh without trouble, the problem is not with ssh.
 
it works :

Code:
mario@marietto:/home/marietto # ssh marietto@192.168.1.7

Microsoft Windows [Version 10.0.22000.778]
(c) Microsoft Corporation. All rights reserved.

marietto@MARIETTO-WINDOW C:\Users\virtu>
 
Back
Top