Chapter 4. Setting up a File Server

In the previous chapter, we covered SSH and discussed SCP. While SCP is a great method to manually transfer individual files from one place to another, having one or more central locations to store shared files adds a lot of value to a network. Whether you're sharing important files on a business network or family photo albums on a home network, a central file storage location on your network is a convenient asset. In this chapter, we'll discuss three ways of accomplishing this goal. We'll first talk about some considerations while designing your file server, and then we'll cover NFS, Samba, and SSHFS.

In this chapter, we will cover:

  • File server considerations
  • NFS v3 versus NFS v4
  • Setting up an NFS server
  • Learning the basics of Samba
  • Setting up a Samba server
  • Mounting network shares
  • Automatically mounting network shares via fstab and systemd
  • Creating networked filesystems with SSHFS

File server considerations

As with most things in the Linux world, there is more than one way of accomplishing any goal. With each method, there are a multitude of best practices and caveats to understand before implementing a solution. As mentioned earlier, the three most common methods of sharing files from one Linux system to another are Network File System (NFS), Samba, and Secure Shell File System (SSHFS). Each of these three primarily serve different needs, and your network layout will determine which you should use.

The first consideration while designing a network file server is what types of platforms will need to access its files. NFS is often a great choice within a Linux-based environment; however, it doesn't handle mixed environments as well, so you may not want to choose it if you have Windows machines on your network that you need to share files with. It's not that you can't access NFS shares on Windows systems (you certainly can), but Microsoft limits NFS availability (called Services for NFS) to the most expensive edition of each version of Windows. Services for NFS is fine if you utilize versions of Windows that support it, but due to the extra licensing hurdle you'd need to overcome, it may make more sense to avoid it. Generally speaking, NFS is a great choice only when your network consists primarily of UNIX and Linux nodes.

Next up for consideration is Samba. Samba allows you to share files between all three major platforms (Windows, Linux, and Mac OSX) and is a great choice within a mixed environment. Since Samba uses the SMB protocol, Windows systems are able to access your Samba shares regardless of the version you have installed, so licensing isn't as much of an issue. In fact, even the standard or home editions of Windows are able to access these shares natively, with no added plugins required for you to install. The downside to Samba is in the way that it handles permissions. When saving files between Windows and Linux nodes, some extra work is required to handle permissions, such that it's not always the best choice when dealing with UNIX or Linux nodes that need to retain specific permissions.

Finally, SSHFS is another method that is primarily geared toward sharing files between Linux nodes. It's certainly possible to connect and access SSHFS from Windows, but only with third-party utilities, as no built-in method exists in Windows (at least at the time this chapter is being written). Where SSHFS shines is its ease of use and the fact that file transfers are encrypted. While encryption certainly helps you to avoid eavesdropping, keep in mind that SSHFS (just like any other solution) is only as secure as the policies you have in place. But in good hands, SSH (and SSHFS) is a secure method of transferring files from one node to another. In addition, SSHFS is the easiest of the three methods listed here to get running. All you need is access to another node and permissions to access one or more directories. That's all you need, and then you're automatically able to create an SSHFS connection to any directory you have access to. Another benefit to SSHFS is that there's nothing to configure on the server other than SSH itself, which most servers have available anyway. SSHFS connections can also be created and disconnected on-demand very quickly. We'll discuss SSHFS later on in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset