How to create a personal file server with SSH on Linux

Connecting to a remote Linux system over SSH is just plain easy. Here's how to do it.
134 readers like this.
Why the operating system matters even more in 2017

Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0

The Raspberry Pi makes for a useful and inexpensive home server for lots of things. I most often use the Raspberry Pi as a print server to share a laser printer with other devices in our home or as a personal file server to store copies of projects and other data.

I use this file server in various ways. Let's say I'm working on a project, such as a new book, and I want to make a snapshot copy of my work and all my associated files. In that case, I simply copy my BookProject folder to a BookBackup folder on the file server.

Or if I'm cleaning up my local files, and I discover some files that I don't really need but I'm not yet ready to delete, I'll copy them to a KeepForLater folder on the file server. That's a convenient way to remove clutter from my everyday Linux system and offload infrequently used files to my personal file server.

Setting up a Raspberry Pi—or any Linux system—as a personal file server doesn't require configuring Network File System (NFS) or Common Internet File System (CIFS) or tinkering with other file-sharing systems such as WebDAV. You can easily set up a remote file server using SSH. And here's how.

Set up SSHD on the remote system

Your Linux system probably has the SSH daemon (sshd) installed. It may even be running by default. If not, you can easily set up SSH through whatever control panel you prefer on your Linux distribution. I run Fedora ARM on my Raspberry Pi, and I can access the control panel remotely by pointing my Pi's web browser to port 9090. (On my home network, the Raspberry Pi's IP address is 10.0.0.11, so I connect to 10.0.0.11:9090.) If the SSH daemon isn't running by default, you can set it to start automatically in Services in the control panel.

sshd in the list of system services

You can find sshd in the list of system services.

slider to activate sshd

Click the slider to activate sshd if it isn't already

Do you have an account?

Make sure you have an account on the remote system. It might be the same as the username you use on your local system, or it could be something different.

On the popular Raspbian distribution, the default account username is pi. But other Linux distributions may require you to set up a unique new user when you install it. If you don't know your username, you can use your distribution's control panel to create one. On my Raspberry Pi, I set up a jhall account that matches the username on my everyday Linux desktop machine.

Set up a new account on Fedora Server

If you use Fedora Server, click the Create new user button to set up a new account.

Set password or SSH key

If you use Fedora Server, click the Create new user button to set up a new account

Optional: Share your SSH public key

If you exchange your public SSH key with the remote Linux system, you can log in without having to enter a password. This step is optional; you can use a password if you prefer.

You can learn more about SSH keys in these Opensource.com articles:

Make a file manager shortcut

Since you've started the SSH daemon on the remote system and set up your account username and password, all that's left is to map a shortcut to the other Linux system from your file manager. I use GNOME as my desktop, but the steps are basically the same for any Linux desktop.

Make the initial connection

In the GNOME file manager, look for the +Other Locations button in the left-hand navigation. Click that to open a Connect to Server prompt. Enter the address of the remote Linux server here, starting with the SSH connection protocol.

Creating a shortcut in GNOME file manager

The GNOME file manager supports a variety of connection protocols. To make a connection over SSH, start your server address with sftp:// or ssh://.

If your username is the same on your local Linux system and your remote Linux system, you can just enter the server's address and the folder location. To make my connection to the /home/jhall directory on my Raspberry Pi, I use:

sftp://10.0.0.11/home/jhall

GNOME file manager Connect to Server

If your username is different, you can specify your remote system's username with an @ sign before the remote system's address. To connect to a Raspbian system on the other end, you might use:

sftp://pi@10.0.0.11/home/pi

GNOME file manager Connect to Server

If you didn't share your public SSH key, you may need to enter a password. Otherwise, the GNOME file manager should automatically open the folder on the remote system and let you navigate.

GNOME file manager connection

Create a shortcut so you can easily connect to the server later

This is easy in the GNOME file manager. Right-click on the remote system's name in the navigation list, and select Add Bookmark. This creates a shortcut to the remote location.

GNOME file manager - adding bookmark

If you want to give the bookmark a more memorable name, you can right-click on the shortcut and choose Rename.

That's it!

Connecting to a remote Linux system over SSH is just plain easy. And you can use the same method to connect to systems other than home file servers. I also have a shortcut that allows me to instantly access files on my provider's web server and another that lets me open a folder on my project server. SSH makes it a secure connection; all of my traffic is encrypted. Once I've opened the remote system over SSH, I can use the GNOME file manager to manage my remote files as easily as I'd manage my local folders.

What to read next
Tags
photo of Jim Hall
Jim Hall is an open source software advocate and developer, best known for usability testing in GNOME and as the founder + project coordinator of FreeDOS.

10 Comments

I'm a little confused about what you mean by "remote server", when you seem to be talking about something on your local network.

"Local" server means a server that's running on the local system. This usually refers to something like a database server that runs on the same server as the web server.

"Remote" server means a server that's running on another system. For example, when a database server lives on a different server than the web server, the database server is a "remote" server to the web server. For best security, the "remote" server typically exists behind a firewall, and sometimes on another network - but "remote" servers can exist on the same subnet too.

So that's how I was using the term "remote server." It's a "remote server" because the SSH file server isn't running on my Linux desktop, but a Raspberry Pi elsewhere on my network.

In reply to by Greg P

That's a good link and reference to spinning down hard drives. In my case, I have quite a lot of free space in /home on my microSD card. Not mentioned in the article is a USB fob drive that's mounted as /backup that I use for other things.

Neither is particularly fast for writing huge amounts of data (like doing a full backup of my regular Linux desktop PC) but it's just fine for making a backup copy of a project folder, or storing some things that I wasn't ready to delete but didn't need to keep.

In reply to by Steve B (not verified)

That was my concern also when I read this.... you should need a public IP address to connect remotely, or can dynamic dns do this?

Years ago I set up a home computer so that I could connect remotely. The first thing you must do is get your ISP to give you a fixed IP address. The second thing is to set up your hostsallow and hostsdeny to allow yourself access but keep out almost everybody else (I've forgotten where these are).
What I found was that IMMEDIATELY you are besieged with attempts from all over the world to log into your system (obviously, there are bots that are constantly looking for IP addresses to get access to), thus the extreme importance of keeping these people out, and you have to keep looking at your logs to see what's going on. In the end, I decided the benefit wasn't worth the anxiety and risk.

In reply to by dadeng

Agree with the contents of the article - however I find (for me at least - your experiences may differ) that it is simpler to use sshfs.

To use it
on your 'server' (the place hosting files):

* install ssh (as above)

on your client

* install sshf

* create a directory (eg ~/Remote)

to use

* sshfs username@remote:/target-directory ~/Remote

#use appropriate substitutions for names

#enter password, if you haven't set up certificates

* use ~/Remote directly to access files on server with same permissions as username has

* when finished, fusermount -u ~/Remote

I think this would make a great article for OpenSource! I encourage you to write an article about using sshfs to mount a filesystem over SSH. You can reach out to the editors to submit your topic.

In reply to by andrew baldwin (not verified)

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.