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.
Advantage of using SSHFS
- Compared to other shared filesystem such as NFS and Samba we do not need any server or client side configuration
- SSHFS is a simple client tool which does not requires any additional configuration
- You can also use SSHFS to transfer files over SSH between Linux and Windows Server
- The files are transferred in completely encrypted channel so it is very secure
Drawbacks of using SSHFS
- You mount the remote directory on local server similar as NFS server but with transfer over SSH using SSHFS both encryption and decryption is involved which can cause performance impacts
- You should also save your data on the mount point as if there is a network connection problem then you may loose your data
Transfer File over SSH between two Linux servers
Install SSHFS on Linux
SSHFS is an opensource project and is not available in most default repositories of distributions
To install SSHFS on RHEL/CentOS 7, we must first install EPEL repository
# yum -y install epel-release
sshfs on your client node
[root@server1 ~]# yum -y install sshfs
sshfs on Ubuntu and Debian
$ sudo apt install sshfs
Mount Remote File System
To transfer files over SSH using SSHFS, we must execute SSHFS using below syntax:
sshfs [user@]host:[dir] mountpoint [options]
sshfs -h to get the complete list of supported options
In this example I have installed SSHFS on
server1 and we will mount
Remote directory (
[root@server2 ~]# ls -l /shared/ total 0 -rw-r--r-- 1 root root 0 May 17 19:21 file1 -rw-r--r-- 1 root root 0 May 17 19:21 file2 -rw-r--r-- 1 root root 0 May 17 19:21 file3
to my local Linux node on
server1 at (
[root@server1 ~]# ls -l /mount_point/ total 0
So we must execute
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
[root@server1 ~]# sshfs email@example.com:/shared /mount_point firstname.lastname@example.org's password:
There was no error reported so the mount was successful. Verify the mount point on
[root@server1 ~]# mount | grep shared
email@example.com:/shared on /mount_point type fuse.sshfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0)
You can now access the content of remote directory (
/mount_point directory on local Linux node at
[root@server1 ~]# ls -l /mount_point/ total 0 -rw-r--r--. 1 root root 0 May 17 19:21 file1 -rw-r--r--. 1 root root 0 May 17 19:21 file2 -rw-r--r--. 1 root root 0 May 17 19:21 file3
Now we can add and modify content under
server1 and the changes will be reflected runtime on
Snippet from my terminal
To permanently mount this remote directory use
/etc/fstab using below syntax:
user@host:/remote/path /local/mount_point fuse.sshfs defaults 0 0
In this example we will add below content in our
firstname.lastname@example.org:/shared /mount_point fuse.sshfs defaults 0 0
Un-mount Remote File System
Once you have transferred your files, you can also un-mount the remote file system using
[root@server1 ~]# umount /mount_point/
Verify and make sure there are no mount paths using /shared directory from remote server i.e.
[root@server1 ~]# mount | grep shared
Transfer File over SSH between Windows and Linux servers
- You can also use SSHFS to transfer files over SSH between Windows and Linux server.
- This can also be achieved using Samba but let us concentrate on SSHFS for the sake of this article
Install SSHFS on Windows
- 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
WinFspand follow the onscreen instructions to install WinFsp on your Windows server
SSHFS-Winand follow the onscreen instructions to install SSHFS-Win on your Windows server
- At the time of writing this article I have installed
Mount Remote File System
Once you have installed
SSHFS-Win on your windows server, next we must map the network location from remote server to a local mount point
I am using WIndows 10 so I will share the instructions based on my environment.
In Windows Explorer select
This PC ⇒
Map Network Drive
Provide the path of your remote server and remote directory using the below syntax
Provide the login credentials for
root user from the remote server i.e.
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
How to connect to different folder using SSHFS in Windows?
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
If you NOTICE, I have first changed my current directory using
../ followed by the path of
/shared directory. I hope you understand the point.
Now we are connected to
/shared directory where we had created three dummy files on
For list of Advanced Usage with Windows SSHFS, check the official Github page for instructions
Disconnect Remote File System
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.
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.
He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can reach out to him on his LinkedIn profile or join on Facebook page.