How To Transfer Files Over SSH With SSHFS in Linux Windows
How To Transfer Files Over SSH With SSHFS in Linux Windows
com /how-to-transfer-files-over-ssh-with-sshfs/
There are various tools available to copy files and directories between Linux server. In this article we will use
SSHFS to transfer files over SSH from local to remote and remote to local server.
You can also use below tools to copy files between Linux servers:
Overview on SSHFS
SSHFS (Secure SHell FileSystem) is a file system for Linux (and other operating systems with a FUSE
implementation, such as Mac OS X or FreeBSD) capable of operating on files on a remote computer
using just a secure shell login on the remote computer.
The sshfs command is a client tool for using SSHFS to mount a remote file system from another server
locally on your machine.
SSHFS allows you to mount a remote directory from remote server on your local machine using a mount
point, and have it treated just like any other directory.
ALSO READ
Learn Linux wheel group usage [With Examples]
SSHFS is an opensource project and is not available in most default repositories of distributions
bash
HINT:
At the time of writing this article, SSHFS was not available for RHEL/CentOS 8
bash
bash
1/6
Mount Remote File System
To transfer files over SSH using SSHFS, we must execute SSHFS using below syntax:
bash
bash
bash
So we must execute sshfs on server1, we are using root user to transfer files over SSH. You can use any
normal user, but make sure this user has enough permission to access the remote directory on server2
bash
There was no error reported so the mount was successful. Verify the mount point on server1
bash
You can now access the content of remote directory (/shared) from server2 on /mount_point directory
on local Linux node at server1
bash
Now we can add and modify content under /mount_point at server1 and the changes will be reflected
runtime on server2 at /shared
2/6
ALSO READ
5 simple methods to test ssh connection in Linux & Unix
To permanently mount this remote directory use /etc/fstab using below syntax:
bash
bash
Once you have transferred your files, you can also un-mount the remote file system using umount. Execute
umount on server1:
bash
Verify and make sure there are no mount paths using /shared directory from remote server i.e. server2
bash
To transfer files over SSH between Windows and Linux, you must install SSHFS on the WIndows server.
You can get the files required to installed from the official Github page
Download WinFsp and follow the onscreen instructions to install WinFsp on your Windows server
Download SSHFS-Win and follow the onscreen instructions to install SSHFS-Win on your Windows
server
At the time of writing this article I have installed winfsp-1.6.20027.msi and sshfs-win-
3.5.20024-x64.msi
Once you have installed WinFsp and SSHFS-Win on your windows server, next we must map the network
location from remote server to a local mount point
ALSO READ
Steps to repair filesystem in rescue mode in RHEL/CentOS 7/8 Linux
Provide the path of your remote server and remote directory using the below syntax
bash
3/6
\\sshfs\REMUSER@HOST[\PATH]
NOTE:
Here we cannot directly give our mount point as /shared from our remote Linux server. We must use (/) to navigate around the
Linux server. In this example we will connect to the home folder of our root user using
bash
\\sshfs\root@192.168.43.10\
Provide the login credentials for root user from the remote server i.e. server2
login credential
If all is good, you will be connected to your remote Linux server using Windows server. You can verify the path
in the Navigation Pane. By default we are connected to home folder of root user
In Windows SSHFS we are by default connected to user's home directory so we must provide the absolute path
using navigation symbols i.e. to go to /shared directory our path to transfer files over SSH on Windows
would be //sshfs/root@192.168.43.10/../shared
If you NOTICE, I have first changed my current directory using ../ followed by the path of /shared
directory. I hope you understand the point.
4/6
Provide different remote directory path
Now we are connected to /shared directory where we had created three dummy files on server2
For list of Advanced Usage with Windows SSHFS, check the official Github page for instructions
Once you are done, to disconnect the network drive, in Windows Explorer select This PC. Look out for
your mapped drive and Right Click on the drive to get a list of options. Select Disconnect to remove the
mapped drive from your Windows server.
ALSO READ
PSSH - 10 practical examples to use parallel SSH in Linux
Conclusion
Lastly I hope the steps from the article to configure NIC teaming on Linux was helpful. In this tutorial we
learned about SSHFS and how we can use SSHFS to transfer files over SSH between two Linux servers or
between Linux and Windows server. So, let me know your suggestions and feedback using the comment
section.
5/6
6/6