其他分享
首页 > 其他分享> > 校园网跨网段共享文件Samba+SSH

校园网跨网段共享文件Samba+SSH

作者:互联网

Introduction

This tutorial contains screenshots for the English version of Windows 10. Separate instructions for older versions of Windows are also available:

To be able to mount a Windows share over SSH we will need

This part of the tutorial is split into the following steps:

    1. As most people do not have a spare real network adapter in their computer, we will add an extra virtual network adapter by installing the Microsoft KM-TEST Loopback Adapter.
    2. After that, the network adapter must be properly configured.
    3. Starting with Windows 10 update 1903, the Windows 10 feature "SMB 1.0" must be turned off.
    4. Furthermore, a few Windows system drivers need to be tweaked.
    5. Next, reboot Windows to verify that we've been able to grab port 445 and to see if the lanmanserver driver is up and running.
    6. Finally, we launch a special OpenSSH session and mount our Nikhef home directory.

 

  1. For those wishing to undo the above steps follow the instructions at the bottom of this tutorial.

Windows 10 Upgrade woes

Multiple persons have reported problems after a major Windows 10 upgrade (e.g. from 1803 to 1809). This is due mostly to the disappearance of the Microsoft KM-TEST Loopback Adapter and of the portproxy rule. In order to recover after a Windows 10 upgrade, try

 

1. Installing the Loopback Adapter

To install the Loopback adapter follow these steps:

You are now ready to configure your newly installed Loopback adapter. Even though Windows might not ask you to, reboot anyways (heey, it's a Microsoft OS ;-)).
From reports I've seen on the Internet a reboot is sometimes required for the loopback adapter to come up properly.

2. Configuring the Loopback Adapter

Now that your newly installed loopback adapter is up and running we must configure it properly:

3. Disabling the "SMB 1.0" Windows feature

Starting with Windows 10 update 1903 we need to disable the Windows feature SMB 1.0:

(Thanks to Michael Uhlenberg for pointing this out)

4. Tweaking the 'LanmanServer' driver

Now we first need to tweak a Windows system driver to overcome the thing that Microsoft broke. The root cause of the problem is that we need to access the file share using TCP port 445. However, when Windows 10 boots this port is grabbed by the system lanmanserver driver for all interfaces. By delaying the startup of the lanmanserver driver and by installing a portproxy rule we can circumvent this. This section explains how to do this:

If all went well you should see something like
ConfigureConsole
The portproxy rule is persistent, so there should be no need to repeat this step after a reboot.

5. Reboot and verify

Of course, now that we have disabled the automatic startup of the 'LanmanServer' driver we have to reboot Windows before proceeding.

On Windows 10 things are slightly different compared to Windows 7 and 8; it seems that Microsoft has read my tutorial and decided to provide a way to use local shares again ;-) !

6. Putting it all together

Now that we have configured both our loopback adapter we can put it all together by launching a special OpenSSH connection and mounting our Nikhef home directory as a Windows share:

Congratulations!

Mapping a network drive

To make life even easier it might be handy to map a network drive to your Nikhef home directory:

7. Control+Z! Undo! Undo!

For those wishing to undo the CIFS-over-SSH trick follow these steps:

  1. Start a console window with elevated (Administrator) privileges.
  2. Restore the automatic startup of the lanmanserver driver by typing
      sc config lanmanserver start= auto
    
    NOTE the space after the start= !
  3. Remove the portproxy rule by typing
      netsh interface portproxy delete v4tov4 listenaddress=10.255.255.1 listenport=445
    
  4. Remove the firewall rule to allow SSH to do portforwarding from 10.255.255.1:
    • Go to the Windows Control Panel
    • Select System and Security, then Windows Defender Firewall
    • Select Allowed apps, and scroll down in the list to SSH, Telnet and Rlogin client and deselect the permissions
      firewallAllowedApps
      Then press OK
  5. Start a Device Manager by typing
      devmgmt.msc
    
    Expand the 'Network Adapters', right-click on Loopback adapter and select Uninstall.
  6. If necessary, use the 'Task Scheduler' from the 'Administrative Tasks' menu to delete the task 'Start LanmanServer driver'
That's all, folks!
reprint:https://www.nikhef.nl/~janjust/CifsOverSSH/Win10Loopback.html#Install

Comments to Jan Just Keijser | lastmod = 26/01/2021 14:42

 

标签:Samba,网段,Windows,adapter,driver,Nikhef,portproxy,校园网,port
来源: https://www.cnblogs.com/1314h/p/15310036.html