SSH (Secure Shell) is a protocol for secure network communication and remote access to networked computers. It provides secure encrypted communications between two untrusted hosts over an insecure network. SSH is often used for remote login and remote file transfer, and is a secure alternative to Telnet and FTP.
With the help of SSHFS, you can easily use your existing SSH connection to mount a remote directory in a secure way, without using additional services like NFS or Samba.
SSHFS (Secure Shell File System) is a file system client based on the SSH protocol that allows users to mount a remote file system over a secure SSH connection. It allows users to access files on a remote server as if they were on the local file system, while providing encrypted data transfer and authentication. SSHFS is often used for remote file access, backup and remote development work.
To install sshfs, type the following command in your terminal:
Command: apt install sshfs
Suppose you have a running SSH server with IP 10.228.0.82, and we want to mount the remote /etc/logstash/conf.d directory locally on ~/root/techhyme.
Let’s create a directory named as “techhyme” under /root.
Now to mount the remote directory we invoke sshfs in the following way:
Command: sshfs firstname.lastname@example.org:/etc/logstash/conf.d/ /root/techhyme
If the command is executed without errors, the content of the remote /root/techhyme directory becomes accessible under the local directory:
Furthermore, the privileges we have on the remote directory are the privileges the remote user has: by default local permissions are ignored by sshfs.
Once the remote directory is mounted, you are able to access its content without problems. If you try to access it as another user, even as root, however, you will fail to mount or list:
This error is due to the fact that, by default, only the user which performs the mount is allowed to access the mounted filesystem.
In order to change this behavior, and allow any user to access the mount point, you must pass the user_allow_other option when using sshfs.
Edit the /etc/fuse.conf file, and remove the comment from the user_allow_other line as shown below:
You should now be able to access the remote directory as any local user (which is allowed to reach the mount point locally, of course). With this setup, any local user will able to perform every action the remote user is entitled to perform on the remote directory.
You may also read:
- SSH Enumeration and Penetration Testing – A Brief Guide
- How to Install Winlogbeat in Windows OS
- [Tutorial] How to Install MobSF on Kali Linux 2022.1
- How To Install Jenkins on Ubuntu Machine
- [Tutorial] How To Install Webmin in Ubuntu
- How to Install Apache Tomcat on Ubuntu Machine
- A Step-by-Step Guide to Installing the LAMP Stack on Ubuntu
- Find OS Version with 5 Different Methods in Windows PowerShell
- [Linux] MySQL: The Easy Way to Check Your Version
- How To Install Remmina in Ubuntu – A Remote Desktop Client