How to mount remote directory in Linux with SSHFS
On the Internet, there is definitely no shortage of file synchronization solutions between the two devices. Google Drive, Microsoft OneDrive, NextCloud, etc . may not give you the official Linux client. But perhaps you do not trust a large corporation in storing your important files. Or, maybe, you want a higher level of security than what NextCloud provides, as there are likely to be unexplored security vulnerabilities in existence.
Why should I use SSHFS?
From an end-user perspective, SSHFS is a simple and very easy to use solution. SSHFS is also extremely secure because it depends on the proven OpenSSH server. SSHFS encryption is also very high, so you can rest assured that no one can steal files during the transfer process. An updated server is correctly configured, only listening to SSH connections, often impossible to crack, unless an attacker comes from NSA or a security specialist, etc. (but maybe they I also don't want to take your files for anything.
Why don't you want to use SSHFS?
If you want the best transfer speed possible, you can use other solutions like NFS. SSHFS is not the slowest option, if your Internet connection is of high quality, it is not the fastest way. And if you want to move folders containing hundreds of small files, this task becomes really terrible. Also, if you want to tweak file sharing settings, based on individual users or other factors, you may want to use another software.
In short, if all you need is an easy, safe, and quick way to synchronize remote folders with a local folder, you'll be happy to use SSHFS.
Install SSHFS
On Arch Linux-based installations, use the following command:
sudo pacman -S sshfs
If you use a Fedora-based distribution, use the following command:
sudo dnf install sshfs
On Debian and Ubuntu, use the command:
sudo apt install sshfs
For OpenSUSE users, enter the following command:
sudo zypper install sshfs
Server configuration
If you rent a server or VPS, the OpenSSH server daemon has been configured. Follow the steps suggested by the cloud service provider to configure the regular user (not the root). Some providers allow you to do this directly from the web control panel and even allow you to enter a public key to access SSH. In this case, create local key pairs using the ssh-keygen
command. Then enter the public key from /home/your_username/.ssh/id_rsa.pub.
If the cloud provider does not provide a tool to easily enter public SSH keys, do this manually. At the very least, do not allow root login and disable password login. Instead, use only SSH keys because they cannot be brute-force attacks, as is the case with passwords.
If you want to synchronize files between two home computers, just consider one as the server (install the openssh-server package and configure) and consider the other computer as a client, then apply the steps the same, similar.
Mount a local remote directory with SSHFS
First, create a folder that will be synchronized with the remote device.
mkdir $HOME/sshfs
Next, mount the local remote directory via SSHFS. Replace the user with the actual user name created on the server and 203.0.113.1 by the actual IP address name of the remote device.
sshfs user@203.0.113.1:/home/user $HOME/sshfs
Of course, if you don't want to synchronize the entire user's home directory on the server side, simply replace / home / user with / home / user / some_other_directory after you create it on the server.
When you want to unmount, use this command:
cd && fusermount -u $HOME/sshfs
If you want a directory to synchronize permanently with the remote device, add a command like sshfs user@203.0.113.1: / home / user $ HOME / sshfs in the autostart manager. Each graphics manager has a different autostart configuration manager, so refer to the help guide for the desktop environment you are using. Some sources recommend adding / etc / fstab, but you should avoid that, because failing to mount the directory may prevent your system from booting completely.
Hope this article is useful for you. If necessary, you can refer to the following link:
https://linux.die.net/man/1/sshfs
Hope you are succesful.
You should read it
- Learn the file system and folders on Linux operating systems
- Format and mount USB in Linux
- How to Remove a TV from a Mount
- How to Create and Use ISO Files on Linux
- Manage folders in Unix / Linux
- Instructions to mount the hard drive into a folder on Windows 10
- Theory - What is Active Directory?
- Directory tree structure in Linux
May be interested
- How to manage remote Linux server using SSHmanaging the server is still a necessary and sometimes heavy task. fortunately, secure shell (ssh) is available - a network protocol that allows services to run on an unsecured network.
- Network communication utilities in Unix / Linuxwhen you work in a distribution environment then you need to communicate with remote users and you also need access to remote unix devices.
- Run remote Linux workstation in Windowsi recently introduced you to a remote connection to windows 7 desktop from a linux computer, and in this article we will show you how to do the opposite.
- What is lost + found folder on Linux and macOS?on linux, users use the fsck (file system check) command to check for corrupted system files. fsck can find corrupted files on the file system. if any files are found to be corrupted, fsck will remove the corrupted data from the file system and move to the lost + found directory.
- How to install and use TeamViewer on Linuxteamviewer is a powerful tool that allows teams to collaborate and share their screens in real time. it is also extremely useful in remote technology support.
- 5 ways to control Linux computer from phonelet's explore some linux tools that bridge the gap between your linux computer and your mobile phone!
- Ryuk Ransomware stops encrypting Linux directoryby putting a bunch of linux directories on the blacklist, the people behind ryuk have removed one more headache that they need to solve.
- Theory - What is Active Directory?what is active directory? active directory is a copyrighted directory service by microsoft, which is an integral part of windows architecture.
- Instructions to mount the hard drive into a folder on Windows 10setting up a mout-point directory path not only minimizes the number of drive letters on your computer, but also helps you organize and manage drives better, even in the rare case can connect to multiple drives.
- Moving files between Linux systems with SCPwhen transferring files to a remote linux server, you have a few options. one of the best is to use a program called secure copy, or scp, which runs over the ssh protocol to quickly transfer files over the network to the remote system.