Last week, I posted a “How To” on how to share files using an FTP server. Unfortunately, FTP is not what is considered secure, for over the internet file transfers. And especially when you’re transferring sensitive data. Thankfully, there is another secure option. In today’s How To, I’ll show you how to share your files the same as before, but using the secure SSH protocol.
The first thing we’ll need to to is install the required package to get the job done. The package is openssh-server. That’s the actual SSH server required to run for other computers to access the computer running the SSH server. And this can be installed using the following command in a terminal:
sudo apt-get install openssh-server
SSH is much easier to setup than an FTP server. And once the server has been installed, there’s almost no configuration changes required to get it running other than allowing access via your firewalls, which I will show you how to do.
Before we actually have access to the SSH server, we must make a few easy changes to the firewall to actually allow for other computers to access the SSH server. If you’re using Ubuntu, then chances are you’re probably using ufw for your system firewall. All you need to do to allow access to the SSH server is type in the following command in to your terminal:
sudo ufw enable
This will ensure the firewall is active and running at system startup. Now type the following:
sudo ufw allow 22
This will open port 22 in the firewall to allow for access to the SSH server. If you do not open this port, other computers will not be able to access your SSH server.
Now that we’ve enabled access via software firewall, we must also enable access via your home network router so that you can access the SSH server over the internet. This will vary depending on your router, so you may have to refer to the router manual to perform these changes.
You need to open port 22 in your router’s firewall and port forward port 22 (SSH) requests to the SSH server’s local IP address. In this instance, the local IP address I am using is 192.168.0.2. But this will vary for every home network.
So now that we’ve installed the SSH server, configured the settings for access and enabled access via both the software and hardware firewall, it’s now time to see whether our SSH server works. If you have followed the above instructions step-by-step, then everything should work correctly. If for some reason you can not connect to the server, the most likely issue will be your firewall settings. Be sure to check over the settings again and ensure you have configured them correctly.
For some simple testing, we need to jump on to a different computer system. For our test, we will boot up Nautilus File Manager as it has built in support for SSH access and other methods of server access.
Launch Nautilus and go to File > Connect to Server. And for Service type, change the option to SSH. In the server setting, you’ll need to type the IP address of the computer we just set up the SSH server on. For this test, I used the local IP 192.168.0.2, but use whatever your own system is using. And also remember, if you are accessing your SSH server over the internet, you need to enter the IP address of the internet connection and not the local IP address. Once you’ve typed in the correct IP address for the server, we need to enter Port 22 for access. In the folder setting, just type in home. And upon login to the SSH server, it will take you directly the /home directory of the file system. And the Username setting is pretty obvious, just type your username to login to the SSH server. Once all of the information is entered, just click Connect and Nautilus should now connect to the SSH server. It will prompt you for your password. Once you enter your password, Nautilus will open up the SSH server directory just like any other local directory on the system.
You should now have full access on the system using FTP. Once you have finished copying your files to or from the server, you should always close the connection. In Nautilus, this is done exactly the same as unmounting any other removable drive media. On the left-hand side pane, you will see an eject icon, click this and Nautilus will disconnect from the SSH server.
That’s it. You now have a full functioning secure SSH server running on your network which can be accessed via any other computer on your home network or over the internet.
If you feel FTP is unsecure for your file transfers between computer systems, then give SSH a try as it is the secure alternative to FTP for general files.