Ubuntu

How to use Ubuntu as a remote fileserver for uploading and downloading files

If you have an old computer, use Ubuntu, or another Linux distribution, to give it a second life as a fileserver

3 months ago

Setting up an old computer to act as a remote fileserver is a lot easier than it sounds. The hard part is just installing Ubuntu, or any other Linux distribution on it. If you're not sure how to do that, Canonical, the company behind Ubuntu, has a great tutorial, which you can read by clicking here. Or, just do a search for "How to install Ubuntu." It's really easy, and there's a lot of great tutorials out there.

So, assuming you've installed Ubuntu and you're ready to go, what's next?


Step 1a: Install an SSH Key on the remote computer

To use our remote computer as a fileserver, we'll be using SSH / SFTP. Open the terminal on Ubuntu (shortcut: ctrl+alt+t) on our remote computer, and type the following:

ssh-keygen

This will create a public/private ssh key pair. By default, it will ask you if you want to save the key in your /home/username/.ssh directory. Press enter to accept the default choice (you can specify a different path if you like). You can also specify a passphrase, but this is optional. Personally however, I always use a passphrase just in case.

Step 1b: Make a copy of the private key

The above command did two things. First, it created a public key with the name id_rsa.pub in our /home/username/.ssh directory. That file stays on the remote computer.

Second, it created a private key with the name id_rsa in the same directory. Open your /home/username/.ssh directory, and copy that file onto something like a thumb drive. You can also email it to yourself as an attachment.


Step 2: Configure your network to accept SSH connections

Now that we have an SSH key on our remote computer, we need to configure the network to which that computer connects to allow incoming SSH connections. This sounds difficult, and it kind of is difficult. However, it doesn't require any strong technical knowledge, or even decent technical knowledge. Just take it slow.

Step 2a: Get your internal and public IP address

Before we do anything else, we need to figure out what internal IP address our remote computer uses when it's just connecting to the local network. In the terminal, type the following command:

ip addr show


There's a lot of unnecessary information for our purposes here. Just take note of what the highlighted text says on your computer.

Next, we need to know what our external IP address is when connecting to the Internet. For this, just do a Google search for "my IP address." That will return your external / public IP address. Make sure to write it down.

Step 2b: Configure our router

What you'll need to do next is change some advanced settings in your network router. To do this, we'll need to access the router's administrative dashboard. Normally, you can find the url for the dashboard on a sticker on the router, along with the username and password. If there's no sticker, check the manual for the router.

In almost all cases, the url is going to be http://192.168.1.1. On Verizon, this will take you to a screen like this one:


Type in the username and password, and log in.

On a Verizon router, go to Firewall then to Port Forwarding. If you don't see a menu option for Firewall, click on Advanced Settings then select Port Forwarding. If your router is not from Verizon and doesn't have these options, do a Google search for your router's brand with the words "port forwarding."

On the port forwarding page, select your computer's internal IP address. And then in the "application to forward" menu, choose SSH or SFTP. If these options are not available, choose custom port and then choose TCP and type in 22 in the port number box:



Step 3: Save the private key on your normal computer

We are done with our remote computer! Now go back to your normal computer, and save the private key there. If you're using Ubuntu or another Linux distribution, I recommend saving it in the /home/username/.ssh directory.

And... that's it! You can now access your old computer using its external IP address and the private key you created from anywhere in the world. If you're on Windows, I recommend using WinSCP or Filezilla.

To connect in a command line terminal, just type the following:

ssh username@remoteExternalIP -i /path/to/ssh/private/key


Step 4: For Linux users, how to easily connect to your remote computer

If you're using Ubuntu or another Linux distribution on your normal computer, it's really easy to connect to your remote computer and mount it as a normal filesystem. To do this on Ubuntu, open the Nautilus File Manager, and go to "Other Locations." From there type ssh://yourRemoteExternalIp into the "Connect to Server" area:


In this case, if you click connect, you'll be prompted for the username and password on your remote computer. But, with a few adjustments, we can use our private key for authentication.

In your /home/username/.ssh directory, create a text file with the name "config". Open that file in a normal text editor, and type the following:

Host {insertCustomNameHere}
    Hostname {insert external IP address of remote computer}
    User {username on remote computer}
    IdentityFile /home/{username on normal computer}/.ssh/id_rsa

Save the file, and go back to the "Other Locations" area. Now just type ssh://CustomNameYouChose into the "Connect to Server" box. After pressing connect, you may need to enter a passphrase if you chose one earlier. Otherwise, voila! That's it. if you open the terminal, you can also connect just by typing:

ssh CustomNameYouChose

Now, that wasn't so bad, right? You can now use your old remote computer as a fileserver from anywhere in the world.

Leave a reply