{"id":1647,"date":"2008-02-05T11:50:58","date_gmt":"2008-02-05T09:50:58","guid":{"rendered":"http:\/\/mummila.net\/nuudelisoppa\/?p=1647"},"modified":"2008-02-05T11:50:58","modified_gmt":"2008-02-05T09:50:58","slug":"ubuntu-setting-up-sshfs-for-elegant-sftp","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2008\/02\/05\/ubuntu-setting-up-sshfs-for-elegant-sftp\/","title":{"rendered":"Ubuntu: setting up SSHFS for elegant SFTP"},"content":{"rendered":"<p>I needed to edit data on my webserver, and initially, still thinking in Windows terms I considered installing <a href=\"http:\/\/en.wikipedia.org\/wiki\/GFTP\">gFTP<\/a>. But then I realized that networking is much more integrated in UNIX, and a separate application is not necessary: mounting my server directory was as simple as choosing to do so with Nautilus&#8217; <code>File &gt; Connect to server<\/code> item and providing the credentials.<\/p>\n<p>But there&#8217;s an even more elegant way of doing things. <a href=\"http:\/\/en.wikipedia.org\/wiki\/SSHFS\">SSHFS<\/a> integrates remote locations into your system seamlessly, allowing you to use them as if they were genuine directories under your local file system.<\/p>\n<p>For Gutsy Gibbon, all I needed to do to get the basic SSHFS functionality going was to install the sshfs package. But then I went ahead and integrated my home directory on the web server so that it&#8217;s now mounted automatically at boot. For this I adapted a set of instructions provided over at <a href=\"http:\/\/www.debuntu.org\/2006\/04\/27\/39-mounting-a-fuse-filesystem-form-etcfstab\">Debian\/Ubuntu Tips &amp; Tricks<\/a>, as well as ones given in an <a href=\"http:\/\/ubuntuforums.org\/showthread.php?t=430312\">Ubuntuforums thread<\/a>.<\/p>\n<p>First, I created the local mount point for the remote location, and gave myself permission to modify it:<\/p>\n<blockquote><p><code>sudo mkdir \/media\/<em>my-remote-login<\/em> <br \/> sudo chown root:fuse \/media\/<em>my-remote-login<\/em> <br \/>  sudo chmod g+w \/media\/<em>my-remote-login<\/em> <br \/> sudo adduser <em>my-login<\/em> fuse<\/code><\/p><\/blockquote>\n<p>Then I added the mount point to <code>\/etc\/fstab<\/code>, adapting <b>Darwin Award Winner<\/b>&#8216;s instructions to my own liking, with the following line (note that it all goes on a single line, the line breaks inserted below are only due to limited column width):<\/p>\n<blockquote><p><code>sshfs#<em>my-remote-login<\/em>@<em>my-web-server<\/em>:<em>path-to-my-remote-home-directory<\/em> \/media\/<em>my-remote-login<\/em> fuse users,uid=<em>my-local-uid<\/em>,gid=<em>my-local-gid<\/em>,reconnect,transform_symlinks,BatchMode=yes 0 0<\/code><\/p><\/blockquote>\n<p>(You&#8217;ll find out your local uid and gid with <code>id<\/code>.)<\/p>\n<p>After this, I had to do a <code>sudo - <em>my-login<\/em><\/code> to activate the changes made to group settings (the adding of <code><em>my-login<\/em><\/code> into <code>fuse<\/code>), before the remote home was mountable (<code>mount \/media\/<em>my-remote-login<\/em><\/code>) with my normal user account. (Otherwise the changes won&#8217;t be in effect until the next log-out and log-in.)<\/p>\n<p>Then I adapted <b>prankst3r<\/b>&#8216;s instructions for establishing trust between my local host and the remote server:<\/p>\n<blockquote><p><code>cd ~ <br \/> ssh-keygen -t rsa<\/code><\/p><\/blockquote>\n<p>I left all the fields, including the passphrase, blank (just pressed enter).<\/p>\n<blockquote><p><code>cd .ssh <br \/> sftp <em>my-remote-login<\/em>@<em>my-web-server<\/em>:<em>path-to-my-remote-home-directory<\/em>\/.ssh <br \/> put id_rsa.pub <br \/> quit <br \/> ssh <em>my-remote-login<\/em>@<em>my-web-server<\/em> <br \/> cd <em>path-to-my-remote-home-directory<\/em>\/.ssh <br \/> cat id_rsa.pub &gt;&gt; authorized_keys <br \/> chmod 600 authorized_keys <br \/> logout<\/code><\/p><\/blockquote>\n<p>After this I was able to log in to the server (<code>ssh <em>my-remote-login<\/em>@<em>my-web-server<\/em><\/code>) without having to type in the password, and after the next boot, my remote home was fully accessible (with read\/write\/execute permissions) from <code>\/media\/<em>my-remote-login<\/em><\/code> with the command-line as well as Nautilus.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed to edit data on my webserver, and initially, still thinking in Windows terms I considered installing gFTP. But then I realized that networking is much more integrated in UNIX, and a separate application is not necessary: mounting my server directory was as simple as choosing to do so with Nautilus&#8217; File &gt; Connect [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-open-source"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=1647"}],"version-history":[{"count":0,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/1647\/revisions"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}