Hello my dear Linux Yogi’s ,
in today’s illustration I am going to show you how you can access any Linux remote file system via SSHFS for example to copy files and folders over securely perhaps over the internet.
Let’s get started
First you have to make sure that ssh server is installed on the remote system. Run the following commands to install ssh server.
sudo apt-get update sudo apt-get install openssh-server
and now check that it is listening and ready for connection with the following command:
sudo netstat -lnp | grep :22
which should return something like the following:
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1169/sshd tcp6 0 0 :::22 :::* LISTEN 1169/sshd
Great! The remote system is ready. Now we have to prepare our system where we like to mount the remote file system. Follow the commands below:
sudo apt-get update sudo apt-get install sshfs
next we have to create a folder where the remote file system will be mounted to:
sudo mkdir -p /media/remotefs
Great everything is now prepared. Let mount the remote file system manually with the following command:
sudo sshfs -o allow_other,default_permissions firstname.lastname@example.org:/ /media/remotefs
if you don’t receive an error message this is actually good news. Remember on Linux that when you execute commandline tools and commands and don’t receive a message is always a good sign. Now lets check our mount with the following command:
and you should receive something similar to this:
Filesystem Size Used Avail Use% Mounted on udev 7.8G 0 7.8G 0% /dev tmpfs 1.6G 58M 1.6G 4% /run /dev/nvme0n1p2 219G 92G 116G 45% / tmpfs 7.8G 218M 7.6G 3% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup /dev/nvme0n1p1 511M 3.6M 508M 1% /boot/efi tmpfs 1.6G 132K 1.6G 1% /run/user/1000 /dev/loop0 77M 77M 0 100% /snap/core/1264 /dev/loop1 65M 65M 0 100% /snap/hexchat/17 /dev/loop2 76M 76M 0 100% /snap/core/1287 /dev/loop3 76M 76M 0 100% /snap/core/1337 email@example.com:/ 13G 4.7G 6.9G 41% /media/remotefs
at the last line you can see our remote file system mount. You can access the remote file system using the following path /media/remotefs.
In order to unmount the remote file system execute the following command:
sudo umount /media/remotefs
That is it and concludes this illustration. Now you know how to manually mount and unmount a remote file system by using sshfs.
I hope you enjoyed his article and take a way some use of it. Please consider to subscribe or register to this blog and forum. If you have any suggestion or ideas for new articles you like to see use my contact form and drop me a line.
Thank you and until next time, Namaste!