« Using Netgear MA521 in Linux | Main | Using Printers from Firefox/Mozilla on Department Unix Environment »

Accessing Windows Directory from Remote

The department has a network drive (smb) available at \\asteria.cs.umd.edu. Windows home directories are accessible from the UNIX systems (via /fs/windows), but sometimes it would be useful if you can access your files with Explorer. Again this is what you can't do from outside without VPN.

The basic approach is to create a SSH connection which forwards an access to localhost:139 (netbios-ssn) to asteria.cs.umd.edu:139. However, this doesn't work well for the following reasons.

1. Port 139 is bound to Windows NetBIOS client by default, so SSH can't use this port unless you disable NetBIOS.
2. Even if you do so, you still can't access a network drive using Explorer because it also uses port 445. There is no way to make Windows release this port, so SSH can't use it. (smbclient only needs port 139, but the purpose here to use Explorer.)

Here I describe a method to avoid these problems. (This method was originally explained in this page written in Japanese.) It uses two additional components: Microsoft Loopback Adapter and stone (http://www.gcd.org/sengoku/stone/.) Microsoft Loopback Adapter is a virtual neetwork adapter included in standard Windows 2k/XP CD. Stone is an application-level TCP/IP repeater developed by H. Sengoku.

1. From control panel, choose "add hardware" and select Microsoft Loopback Adapter. ("Add new device"->"Choose from list"->"Network adapter"->"Microsoft"->"Microsoft Loopback Adapter")
2. Open the property of the Loopback Adapter in the local-area network. Remove all checks except TCP/IP. In the property of TCP/IP, Enter an IP address that is *different* from your actual LAN address. (Here I assume you have chosen 192.168.2.250 as the IP address and 255.255.255.0 as the netmask. This means your LAN must not be 192.168.2.0/24.) In the advanced setting, disable NetBIOS over TCP/IP.
3. Download the binary package of stone from here and extract it to your preferred location. In the command prompt window, run the following command.
> stone localhost:8139 192.168.2.250:139
Here I further assumed that you use port 8139 for port-forwarding. You can change it to any number. (Large number is recommended in general.) Leave this program open while you access network drives.
4. Begin port forwarding using the following command (more about SSH: here)
$ ssh -L 8139:asteria.cs.umd.edu.edu:139 (your username)@(dept unix hostname)
5. Now open Explorer, and enter "\\192.168.2.250" in the address bar. You'll be asked a username (use "umd-csd-nt\...") and a password, then you can access your Windows directory!