Accessing a Samba Share Remotely

While procrastinating hard in the library, I was taken by a sudden desire to listen to some music from my ever-expanding collection. The only slight drawback was that I'd left my iPod at home, which made it somewhat difficult given that my laptop is devoid of any music.

Realising that my desktop PC has its music shared (using Samba) with the rest of the home LAN, I set about trying to connect to it from my laptop on the University's VPN.

On Windows, the process is as follows:

  1. Execute net stop server from the command prompt (Win+R>cmd>OK). This stops Windows' Samba server on the local machine (we're effectively replacing the local server with the remote one).
  2. Open PuTTY and select the 'Tunnels' option from the 'SSH' menu in the left-hand pane
  3. For each of the following port numbers: 137, 138, 139, 445; enter the port number in the 'Source port' entry box and hostname:X (where hostname is the name of the box with the Samba shares, and X is the same port number you put in the 'Source port' box) in the 'Destination' entry box, and then click the 'Add' button.
  4. Return to the 'Session' option at the top of the left hand pane and enter the name of the remote host you're connecting to (in general, the hostname of the internet gateway on the home LAN).
  5. It's probably a good idea to save this little setup for future use, so give it a name in the 'Saved Sessions' box and hit 'Save'.
  6. Click the 'Open' button, and enter your username and password when prompted (assuming you don't have SSH keys set up...)
  7. You should now be able to enter \\127.0.0.1 in the Windows 'Run' box, and after authenticating with a valid Samba username and password you'll be presented with all the visible shares of the remote machine. These can be browsed and mapped to network drives, as with any Samba share.
  8. That's it!

Of course, this makes several assumptions - you need to have a machine on the home LAN you can SSH into, for one. But it's a simple hack that seems to work. It's also got the added benefit of being encrypted.

Something like Icecast would probably be a more sensible long-term solution, but for a quick and easy way of listening to your tracks, it does the job nicely. :)

date: Mon Jan 23 18:30:06 2006 | permalink | tags: linux howto music