Archive for September, 2007

Access Network Shares over the Internet

Sunday, September 2nd, 2007

Note: I tend to ramble and build up to the point by painting a wonderful picture in words… Straight onto The Point

I tend to have a slightly complicated setup at work as far as my files go. For the most part, it’s the same as anyone else’s. Email in my email client, documents in My Documents and shared stuff on the central network share. Bu the files I spend most of my time on are stored on another server. The setup is something like this:

  • Desktop running Windoze XP with a Network Share mapped to X:
  • Linux box running Redhat with Samba and a username/password protected share with all my web files on it
  • Dreamweaver accesses the network share and FTPs to a range of production servers when ready

There’s a couple of reasons for storing everything on a central Linux box and not on a local drive:

  1. They get included in an automated backup routine that backs up all remote and local files into one archive to be moved offsite on my laptop
  2. The root directory of the Samba share is also the root directory of the Apache installation so I can test stuff locally

When away from the office I tend to FTP to the production server I want and make any changes, FTP them back and then either email myself a reminder to download them when I get into the office or Remote Desktop in and download them straight away. This has always worked and although it’s a bit of bind, noone likes working on the weekend so it means I don’t fire up my laptop to do little bits of bug fixing or whatever on a quiet Sunday.

This morning though I got an email off the MD saying I could do with a new desktop and he’d a catalogue through with a few offers in. I put the kettle on and headed over to www.dell.co.uk to see which ones he was on about. Unfortunately by the time I’d added the options I wanted (RAM, Dual Screen) it was about twice what it was to begin with. I’m now trying to convince him on a nice single monitor spec but with a 22″ wide screen TFT instead, but that’s a bit off point (I haven’t even got to the point yet, but hey!).

While I was waiting to see if he was willing to re-mortgage his house just to buy me a new PC, I thought I’d have a look at improving the rest of my work setup and that’s when I decided to find out if I could access the network share from home as well. I so couldn’t be bothered with a VPN so after a bit of Googling about other options I decided the easiest optikon was to set up a SSH tunnel and send all SMB (port 139) traffic through that.

The Whole Point Of This
Here’s a step by step guide of how you do this in case you want to access Network Shares accross the Net. If some things are called slightly different things on your machines, don’t worry, that’s just because I couldn’t be bothered to look at what they were called, I’m just doing it from memory.

  1. Boot up the PC that you want to access the Network Share from, i.e. accross the Internet (call it the client)
  2. Go to Start > Control Panel > Network Connections
  3. Open any of your connections and go to Properties. Click on “File & Print Sharing” and hit Unistall
  4. Reboot (only time, honest)
  5. Download and save Putty
  6. Open it up and enter the address of the server which has the network share on it*
  7. Go down to SSH > Tunels and in the Source box put 139, then in Destination put yourdomain.com:139 and hit Add
  8. Go back to Session and Save. This just makes it a double click to load up next time
  9. Connect, enter your username and password for the server
  10. Go to My Computer and go Tools > Map Network Drive
  11. Choose any drive letter you want and then in Folder put \\127.0.0.1\sharename (plus any username and password info you need

You should now have access to your remote Network Share from wherever you are! The speed will depend on the internet connections at both ends plus how busy the net inbetween is. For loading up and editing the 12K PHP files I use, it’s perfectly fine. I’ve also copied accross a 22M zip file but was writing this so didn’t see how long it took. I’m now copying across a 540M zip file to see how long that might take (I’m guessing about 20 times faster than doing it through Remote Desktop) [took about 3 and 1/2 hours on 512kb connection].

I haven’t mentioned security here. SSH means that while copying files across you’ll be pretty safe but I’ve gone the whole hog and blocked SSH acess to everywhere but my home IP just to make sure (no, this isn’t my work or home server). It’s up to you how far you go on the security.

* I’m assuming you’ve got a share running, a SSH server running and can open up SSH traffic to it through your firewall as well as all the necessary security/authentication