Now we’ve all been in a situation where we wished to be able to access something in our home network. Some of us even own a home server, and even fewer people actually set up the home server web interface (speaking of Windows Home Servers, that is). It’s a bit difficult to do, and in my case, I for some reason couldn’t be bothered to reconfigure it after I had to exchange my home server on warranty. So, now, I was finding myself at another place in time and space, and was left with no real way to access that file I needed so badly over the air. So, what do you do in such a situation? You get inventive.
For my next trick, I will require:
- A functioning internet connection at home, and an already configured DynDNS service so you can actually access your home network
- A home server (that’s currently on)
- A raspberry pi or other Linux-powered device (that’s currently on)
- A shell (no, not the one you find on the beach. The Linux one)
- A good bit of time and imagination
Let’s get started, shall we?
Now we could do some magic with sshfs, which would be the proper way. But imagine you find yourself at a friend’s house and want to access, let’s say, last year’s holiday videos. You want a quick and dirty way to access the files that are not directly available on the internet. So, we shall take a different route: We will connect to the RasPi (or Linux Box), mount the Windows Home Server CIFS share, and reroute it into our local webserver’s file. Once all of that is done, it should be easy as 3.1415 to actually access those files.
Establishing the connection.
Our tutorial requires a bit of luck. Or, you could also say, a bit of precaution. Being the good programmy person that you are, you of course already set up your home router to forward your ssh ports to your linux device of choice, be it a RasPi, a BananaPi, or whatever other products with the name of pastry might be out there that resemble a linux box. Typically, that would be port 22. So, how about you do a simple
and see if this works? It does? Great. That means the biggest hurdle is already overcome. From hereon, it’s a pretty straightforward process.
Naturally, you would have already installed a lightweight server distribution on your raspberry pi by now that you can access over my-home-network-addr.net (or, maybe even better, with HTTPS). Before we work our way through the actual mounting, let’s create a mountpoint. Ideally, you’d put that somewhere where you can remember. So
mkdir a folder of your choice in an accessible location. So, now, we can just go ahead and do some mount magic. Please
sudo up that
nano and add the following line to your
/etc/fstab file, and alter as needed.
//IP.OF.YOUR.HOME.SERVER/Path/To/Desired/Folders /your/mountpoint/goes/here cifs username=Your_Username_Goes_Here,password=Guess_What_Goes_Here,workgroup=your_workgroup,users,auto,user_xattr 0 0
Now, save all of this and execute that sweet sweet
sudo mount -a. Now, if you
cd yourself into the mountpoint of your choice, you should already see all the desired files. Smells like victory already, doesn’t it? That’s right. Now, only add a
ln -s the desired parts of your mountpoint into your
/var/www folder to make sure it’s accessible over HTTP. At this point, if you have directory listing enabled, you should already be good to go, and your files should be available to download via HTTP on any PC you’d like to try it.
As a bonus exercise, do all of this on Android via some SSH implementation to show a friend running Windows a couple of photos. 😛
I might do a couple of tutorials about how to install the requirements for your server (DynDNS, Lighttpd, MySQL, PHP, and so), but I’m not going to lie, that will heavily reply on my daily feeling. So, stay tuned, and feel good with all the stuff you accomplished today!