{"id":4409,"date":"2018-03-26T14:45:47","date_gmt":"2018-03-26T17:45:47","guid":{"rendered":"https:\/\/blog.clusterweb.com.br\/?p=4409"},"modified":"2018-05-31T13:16:41","modified_gmt":"2018-05-31T16:16:41","slug":"mounting-ftp-host-to-local-directory-on-top-of-fuse","status":"publish","type":"post","link":"https:\/\/blog.clusterweb.com.br\/?p=4409","title":{"rendered":"MOUNTING FTP HOST TO LOCAL DIRECTORY ON TOP OF FUSE"},"content":{"rendered":"<p>I have wrote a post regarding on\u00a0how to access ftp host using curl. And this time, let us look at how to mount the ftp host to a local directory on top of FUSE.<\/p>\n<p><a href=\"https:\/\/fuse.sourceforge.net\/\">FUSE<\/a>\u00a0(Filesystem in userland) is a userland build on top of virtual filesystem, it allows you to implement functional filesystem in userspace application. Robson Braga Araujo wrote an app based on fuse and curl that allows you to mount a ftp host to a local directory,\u00a0<a href=\"https:\/\/curlftpfs.sourceforge.net\/\">curlftpfs<\/a>.<\/p>\n<p><strong>What is the benefit of mounting ftp host to a local directory?<\/strong><br \/>\nThe most obvious benefit is easing file management in ftp host. After mounting ftp host to a local dir, you can simply copy, move and delete files using command such as cp, mv, rm. You can easily transfer files from your localhost to ftp host and vice versa.<\/p>\n<p><!--more--><\/p>\n<p>To mount ftp host to your local directory, first you need to create a local directory, I created a folder \u2018myftp\u2019 and mounting it like this<\/p>\n<pre><code>sudo curlftpfs -o allow_other ftp:\/\/myusername:mypassword@ftp.mydomain.com myftp<\/code><\/pre>\n<p>As simple as that, you are now able to access your ftp host locally.<\/p>\n<p><strong>How to unmount it?<\/strong><br \/>\nUnmount works as usual.<\/p>\n<pre><code>sudo umount myftp<\/code><\/pre>\n<p><strong>The command line is lengthy for me, can I auto mount my ftp host by putting it to \/etc\/fstab ?<\/strong><br \/>\nYes, curlftpfs support that.<br \/>\nInject this line to\u00a0<em>\/etc\/fstab<\/em><\/p>\n<pre><code>curlftpfs#myusername:mypassword@ftp.mydomain.com \/mnt\/myftp fuse allow_other,rw,user,noauto 0 0<\/code><\/pre>\n<p>With\u00a0<em>noauto<\/em>\u00a0option, this mount point will not be auto mount when your system restart, you need mount it manually. But this time, you do not need to type the long command line, you now can do this:<\/p>\n<pre><code>sudo mount \/mnt\/myftp<\/code><\/pre>\n<p>You may observed that I use\u00a0<strong>allow_other<\/strong>\u00a0in the option, so that I can access \/mnt\/myftp without need to change myself to root.<\/p>\n<p><strong>Security Issues<\/strong><br \/>\nTry to run the command line below:<\/p>\n<pre><code>ps aux | grep curlftpfs<\/code><\/pre>\n<p>OMG! my username and password of my ftp host is visible. I am very sensitive about this, I don\u2019t want it to be so visible, what should I do?<\/p>\n<p>You can create .netrc under root directory and modified the mount line in \/etc\/fstab.<\/p>\n<p>1. Create \/root\/.netrc and paste these lines in it.<\/p>\n<pre><code>machine ftp.byexamples.com\r\nlogin myusername\r\npassword mypassword<\/code><\/pre>\n<p>2. Modified the user mode of the file<\/p>\n<pre><code>sudo chmod o-rw \/root\/.netrc<\/code><\/pre>\n<p>3. Modified \/etc\/fstab<\/p>\n<pre><code>curlftpfs#ftp.mydomain.com \/mnt\/myftp fuse allow_other,rw,user,noauto 0 0<\/code><\/pre>\n<p>Although your \/root\/.netrc is in plain text, but you will need to gain root privilege in order to access the file.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have wrote a post regarding on\u00a0how to access ftp host using curl. And this time, let us look at how to mount the ftp host to a local directory on top of FUSE. FUSE\u00a0(Filesystem in userland) is a userland build on top of virtual filesystem, it allows you to implement functional filesystem in userspace [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[477,1082,730,1,42,51,495,68,271,501],"tags":[836,938,1149,1146,216,1145,1148,923,921,1147],"class_list":["post-4409","post","type-post","status-publish","format-standard","hentry","category-backup-2","category-centos-7-rhel-7","category-clusterweb","category-viazap","category-leitura-recomendada","category-linux-linuxrs","category-profissional-de-ti","category-redes-2","category-seguranca-2","category-shell-script","tag-directory","tag-ftp","tag-fuse","tag-host","tag-local","tag-mounting","tag-of","tag-on","tag-to","tag-top"],"_links":{"self":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4409"}],"version-history":[{"count":2,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4409\/revisions"}],"predecessor-version":[{"id":4438,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=\/wp\/v2\/posts\/4409\/revisions\/4438"}],"wp:attachment":[{"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.clusterweb.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}