{"id":12762,"date":"2019-03-28T19:04:08","date_gmt":"2019-03-28T19:04:08","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12762"},"modified":"2019-03-28T19:04:08","modified_gmt":"2019-03-28T19:04:08","slug":"how-to-mount-remote-linux-filesystem-or-directory-using-sshfs-over-ssh","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-mount-remote-linux-filesystem-or-directory-using-sshfs-over-ssh\/","title":{"rendered":"How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH"},"content":{"rendered":"<p>The main purpose of writing this article is to provide a step-by-step guide on how to mount remote Linux file system using\u00a0<strong>SSHFS<\/strong>\u00a0client over\u00a0<strong>SSH<\/strong>.<\/p>\n<p>This article is useful for those users and system administrators who want to mount remote file system on their local systems for whatever purposes. We have practically tested by installing\u00a0<strong>SSHFS<\/strong>\u00a0client on one of our Linux system and successfully mounted remote file systems.<\/p>\n<p>Before we go further installation let\u2019s understand about\u00a0<strong>SSHFS<\/strong>\u00a0and how it works.<\/p>\n<div id=\"attachment_22197\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sshfs-Mount-Remote-Linux-Filesystem-Directory.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22197\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2012\/08\/Sshfs-Mount-Remote-Linux-Filesystem-Directory.png\" alt=\"Sshfs Mount Remote Linux Filesystem or Directory\" width=\"720\" height=\"345\" aria-describedby=\"caption-attachment-22197\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22197\" class=\"wp-caption-text\">Sshfs Mount Remote Linux Filesystem or Directory<\/p>\n<\/div>\n<h3>What Is SSHFS?<\/h3>\n<p><strong>SSHFS<\/strong>\u00a0stands for (<strong>Secure SHell FileSystem<\/strong>) client that enable us to mount remote filesystem and interact with remote directories and files on a local machine using\u00a0<strong>SSH<\/strong>\u00a0File Transfer Protocol (<strong>SFTP<\/strong>).<\/p>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/sftp-command-examples\/\" target=\"_blank\" rel=\"noopener\">10 sFTP Command Examples to Transfer Files on Remote Servers in Linux<\/a><\/p>\n<p><strong>SFTP<\/strong>\u00a0is a secure file transfer protocol that provides file access, file transfer and file management features over Secure Shell protocol. Because\u00a0<strong>SSH<\/strong>\u00a0uses encryption while transferring files over the network from one computer to another computer and\u00a0<strong>SSHFS<\/strong>\u00a0comes with built-in FUSE (<strong>Filesystem in Userspace<\/strong>) kernel module that allows any non-privileged users to create their file system without modifying kernel code.<\/p>\n<p>In this article, we will show you how to install and use\u00a0<strong>SSHFS<\/strong>\u00a0client on any Linux distribution to mount remote Linux filesystem or directory on a local Linux machine.<\/p>\n<h4>Step 1: Install SSHFS Client in Linux Systems<\/h4>\n<p>By default\u00a0<strong>sshfs<\/strong>\u00a0packages does not exists on all major Linux distributions, you need to enable\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-enable-epel-repository-for-rhel-centos-6-5\/\" target=\"_blank\" rel=\"noopener\">epel repository<\/a>under your Linux systems to install sshfs with the help of\u00a0<strong>Yum<\/strong>\u00a0command with their dependencies.<\/p>\n<pre># yum install sshfs\r\n# dnf install sshfs              [On <strong>Fedora 22+<\/strong> releases]\r\n$ sudo apt-get install sshfs     [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]\r\n<\/pre>\n<h4>Step 2: Creating SSHFS Mount Directory<\/h4>\n<p>Once the sshfs package installed, you need to create a mount point directory where you will mount your remote file system. For example, we have created mount directory under\u00a0<code>\/mnt\/tecmint<\/code>.<\/p>\n<pre># mkdir \/mnt\/tecmint\r\n$ sudo mkdir \/mnt\/tecmint     [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]\r\n<\/pre>\n<h4>Step 3: Mounting Remote Filesystem with SSHFS<\/h4>\n<p>Once you have created your mount point directory, now run the following command as a\u00a0<strong>root<\/strong>\u00a0user to mount remote file system under\u00a0<code>\/mnt\/tecmint<\/code>. In your case the mount directory would be anything.<\/p>\n<p>The following command will mount remote directory called\u00a0<code>\/home\/tecmint<\/code>\u00a0under\u00a0<code>\/mnt\/tecmint<\/code>\u00a0in local system. (Don\u2019t forget replace\u00a0<strong>x.x.x.x<\/strong>\u00a0with your IP Address and mount point).<\/p>\n<pre># sshfs tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint\r\n$ sudo sshfs -o allow_other tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint     [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]\r\n<\/pre>\n<p>If your Linux server is configured with SSH key based authorization, then you will need to specify the path to your public keys as shown in the following command.<\/p>\n<pre># sshfs -o IdentityFile=~\/.ssh\/id_rsa tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint\r\n$ sudo sshfs -o allow_other,IdentityFile=~\/.ssh\/id_rsa tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint     [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]\r\n<\/pre>\n<h4>Step 4: Verifying Remote Filesystem is Mounted<\/h4>\n<p>If you have run the above command successfully without any errors, you will see the list of remote files and directories mounted under\u00a0<code>\/mnt\/tecmint<\/code>.<\/p>\n<pre># cd \/mnt\/tecmint\r\n# ls<\/pre>\n<pre>[root@ tecmint]# ls\r\n12345.jpg                       ffmpeg-php-0.6.0.tbz2                Linux                                           news-closeup.xsl     s3.jpg\r\ncmslogs                         gmd-latest.sql.tar.bz2               Malware                                         newsletter1.html     sshdallow\r\nepel-release-6-5.noarch.rpm     json-1.2.1                           movies_list.php                                 pollbeta.sql\r\nffmpeg-php-0.6.0                json-1.2.1.tgz                       my_next_artical_v2.php                          pollbeta.tar.bz2<\/pre>\n<h4>Step 5: Checking Mount Point with df -hT Command<\/h4>\n<p>If you run\u00a0<strong>df -hT<\/strong>\u00a0command you will see the remote file system mount point.<\/p>\n<pre># df -hT<\/pre>\n<h5>Sample Output<\/h5>\n<pre>Filesystem                          Type        Size  Used Avail Use% Mounted on\r\nudev                                devtmpfs    730M     0  730M   0% \/dev\r\ntmpfs                               tmpfs       150M  4.9M  145M   4% \/run\r\n\/dev\/sda1                           ext4         31G  5.5G   24G  19% \/\r\ntmpfs                               tmpfs       749M  216K  748M   1% \/dev\/shm\r\ntmpfs                               tmpfs       5.0M  4.0K  5.0M   1% \/run\/lock\r\ntmpfs                               tmpfs       749M     0  749M   0% \/sys\/fs\/cgroup\r\ntmpfs                               tmpfs       150M   44K  150M   1% \/run\/user\/1000\r\n<strong>tecmint@192.168.0.102:\/home\/tecmint fuse.sshfs  324G   55G  253G  18% \/mnt\/tecmint<\/strong>\r\n<\/pre>\n<p><b>Suggested Read:<\/b>\u00a0<a href=\"https:\/\/www.tecmint.com\/how-to-check-disk-space-in-linux\/\" target=\"_blank\" rel=\"noopener\">12 Useful \u201cdf\u201d Commands to Check Disk Space in Linux<\/a><\/p>\n<h4>Step 6: Mounting Remote Filesystem Permanently<\/h4>\n<p>To mount remote filesystem permanently, you need to edit the file called\u00a0<code>\/etc\/fstab<\/code>. To do, open the file with your favorite editor.<\/p>\n<pre># vi \/etc\/fstab\r\n$ sudo vi \/etc\/fstab     [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]         \r\n<\/pre>\n<p>Go to the bottom of the file and add the following line to it and save the file and exit. The below entry mount remote server file system with default settings.<\/p>\n<pre>sshfs#tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint fuse.sshfs defaults 0 0\r\n<\/pre>\n<p>Make sure you\u2019ve\u00a0<a href=\"https:\/\/www.tecmint.com\/ssh-passwordless-login-using-ssh-keygen-in-5-easy-steps\/\" target=\"_blank\" rel=\"noopener\">SSH Passwordless Login<\/a>\u00a0in place between servers to auto mount filesystem during system reboots..<\/p>\n<p>If your server is configured with SSH key based authorization, then add this line:<\/p>\n<pre>sshfs#tecmint@x.x.x.x:\/home\/tecmint\/ \/mnt\/tecmint fuse.sshfs IdentityFile=~\/.ssh\/id_rsa defaults 0 0<\/pre>\n<p>Next, you need to update the fstab file to reflect the changes.<\/p>\n<pre># mount -a\r\n$ sudo mount -a   [On <strong>Debian<\/strong>\/<strong>Ubuntu<\/strong> based systems]\r\n<\/pre>\n<h4>Step 7: Unmounting Remote Filesystem<\/h4>\n<p>To unmount remote filesystem, jun issue the following command it will unmount the remote file system.<\/p>\n<pre># umount \/mnt\/tecmint<\/pre>\n<p>That\u2019s all for now, if you\u2019re facing any difficulties or need any help in mounting remote file system, please contact us via comments and if you feel this article is much useful then share it with your friends.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/sshfs-mount-remote-linux-filesystem-directory-using-ssh\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The main purpose of writing this article is to provide a step-by-step guide on how to mount remote Linux file system using\u00a0SSHFS\u00a0client over\u00a0SSH. This article is useful for those users and system administrators who want to mount remote file system on their local systems for whatever purposes. We have practically tested by installing\u00a0SSHFS\u00a0client on one &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/how-to-mount-remote-linux-filesystem-or-directory-using-sshfs-over-ssh\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Mount Remote Linux Filesystem or Directory Using SSHFS Over SSH&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12762","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12762"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12762\/revisions"}],"predecessor-version":[{"id":12763,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12762\/revisions\/12763"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}