Hands-on lab – sharing a directory with SSHFS

For this lab, we'll use two VMs. For the server, you can use Ubuntu, CentOS 7, or CentOS 8. The client can be either Ubuntu or CentOS 7. (At the time of writing, CentOS 8 still doesn't have the client package that we need to install for this. But, as I keep saying, that might change by the time you read this.) Let's get started:

  1. Boot up one VM for a server. (That's all you need to do for the server end.)
  2. On the other VM that you'll use as a client, create a mount-point directory within your own home directory, like so:
mkdir remote
  1. On the client VM, install the SSHFS client. On Ubuntu, do the following:
sudo apt install sshfs

On CentOS 7, do the following:

sudo yum install fuse-sshfs
  1. From the client machine, mount your own home directory that's on the server:
sshfs [email protected]: /home/donnie/remote
Note that if you don't specify a directory to share, the default is to share the home directory of the user account that's being used for logging in.
  1. Verify that the directory was mounted properly with the mount command. You should see your new shared mount at the bottom of the output:
donnie@ubuntu-nftables:~$ mount
. . .
. . .
[email protected]: on /home/donnie/remote type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=1000,group_id=1004)
  1. cd into the remote directory and create some files. Verify that they actually do show up on the server.
  2. At the local console of the server VM, create some files in your own home directory. Verify that they show up in the remote directory of your client VM.

You've reached the end of the lab – congratulations!

With this lab, I just showed you how to mount your own home directory from a remote server. You can also mount other server directories by specifying them in the sshfs command. For example, let's say that I want to mount the /maggie_files directory, with the ~/remote3 directory as my local mount-point. (I chose that name because Maggie the cat is sitting here in front of me where my keyboard should be.) Just do the following:

sshfs [email protected]:/maggie_files /home/donnie/remote3

You can also make the remote directory automatically mount every time you boot your client machine by adding an entry to the /etc/fstab file. But, that's generally not a good idea. If the server isn't available when you boot the client machine, it could cause the boot process to hang up.

Okay, so you've seen how to use SSHFS to create an encrypted connection with a shared remote directory. Now let's log into the server from a Windows desktop machine.

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

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