<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Peter's Blog - Nodes for sshfs</title>
    <link>http://www.petersblog.org/</link>
    <description>Nodes containing the tag sshfs</description>
    <item>
      <title>Automounting</title>
      <link>http://www.petersblog.org/node/view/1635</link>
      <description>&lt;p&gt;
I have a number of pcs running linux now that I have hooked together. Copying files between them is a matter of uttering scp invocations along the lines of 
&lt;/p&gt;
&lt;pre class="lazy"&gt;scp me@there:/path/to/file &lt;span class="Keyword"&gt;~&lt;/span&gt;/put/it/there
&lt;/pre&gt;
&lt;p&gt;
With ssh keys set up there is no need to enter a password but still this precludes the use of luxuries like file browsers. To cover this there is sshfs which invisibly turns an sftp login into a file system so the files on the remote box look like they are on the local hard disk. But then there is still the hassle of mounting them when you want to use them. 
&lt;/p&gt;
&lt;p&gt;
Along comes autofs and this is coolness, it means that the connection to the server is made automatically whenever one tries to access the file. The connection will disconnect automatically if it is not used so it is not permanently using resources like an fstab entry would. 
&lt;/p&gt;
&lt;p&gt;
Peter's notes: 
&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
switch to root 
&lt;pre class="lazy"&gt;sudo -i
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
enter 
&lt;pre class="lazy"&gt;ssh-keygen
&lt;/pre&gt;
and keep pressing enter until it stops hassling you 
&lt;/li&gt;
&lt;li&gt;
enter 
&lt;pre class="lazy"&gt;ssh-copy-id user@server
&lt;/pre&gt;
where user@server is the remote account you want to sftp to. ssh-copy-id is my BIG discovery today, it sticks your public key in the remote servers ~/.ssh/authorized_keys file saving much tedium. 
&lt;/li&gt;
&lt;li&gt;
run 
&lt;pre class="lazy"&gt;aptitude install autofs sshfs
&lt;/pre&gt;
and press Y if it asks. 
&lt;/li&gt;
&lt;li&gt;
vim /etc/auto.master and add: 
&lt;pre class="lazy"&gt;/mnt/ssh /etc/auto.sshfs        uid=1000,gid=1000,--timeout=30,--ghost
&lt;/pre&gt;
which maps anything in /mnt/ssh to an automatic file system. Your /mnt directory should already exist but /mnt/ssh will be created for you by autofs. 
&lt;/li&gt;
&lt;li&gt;
vim /etc/auto.sshfs and add your shares: 
&lt;pre class="lazy"&gt;desktop  -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs&lt;span class="Constant"&gt;\#&lt;/span&gt;peter@desktop&lt;span class="Constant"&gt;\:&lt;/span&gt;/
&lt;/pre&gt;
this links /mnt/ssh/desktop to the root directory of my desktop pc. 
&lt;/li&gt;
&lt;li&gt;
run 
&lt;pre class="lazy"&gt;/etc/init.d/autofs restart
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;
exit out of the sudo 
&lt;/li&gt;
&lt;li&gt;
run 
&lt;pre class="lazy"&gt;ls /mnt/ssh/desktop
&lt;/pre&gt;
and relish how cool all this is. 
&lt;/li&gt;&lt;/ul&gt;

&lt;div class="picture"&gt;&lt;div class="pictureframe"&gt;&lt;a href="/pictures/0000/0028/AutofsSshfs.png" rel="lightbox" title="Autofs plus Sshfs"&gt;&lt;img alt="Autofs plus Sshfs" src="/pictures/0000/0028/AutofsSshfs_normal.png"&gt;&lt;/a&gt;&lt;br/&gt;&lt;p&gt;Autofs plus Sshfs&lt;/p&gt;&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;
On the left, my desktop as viewed from the Mythical Convergence Box, on the right Peter's Blog on &lt;a href="/tag/slicehost"&gt;Slicehost&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
An important thing to underline is that since the connection is made as root it is necessary for root to have an ssh key to the ssh account that is sharing the files, NOT from your own user account. 
&lt;/p&gt;
&lt;p&gt;
Since this uses sftp it is secure and easy to pass through firewalls etc. I copied 9G of photos over  the link from desktop to convergence box in maybe ten minutes so the performance is reasonable. 
&lt;/p&gt;
&lt;p&gt;
Thanks to &lt;a href="http://www.mccambridge.org/blog/2007/05/totally-seamless-sshfs-under-linux-using-fuse-and-autofs/"&gt;this guy&lt;/a&gt; who figured out the incantations. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href="/tag/autofs"&gt;autofs&lt;/a&gt; &lt;a href="/tag/sshfs"&gt;sshfs&lt;/a&gt; &lt;a href="/tag/trydoingthisinwindows"&gt;trydoingthisinwindows&lt;/a&gt; &lt;a href="/tag/ubuntu"&gt;ubuntu&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/1635</guid>
      <category domain="http://www.technorati.com/tag">autofs</category>
      <category domain="http://www.technorati.com/tag">sshfs</category>
      <category domain="http://www.technorati.com/tag">trydoingthisinwindows</category>
      <category domain="http://www.technorati.com/tag">ubuntu</category>
    </item>
  </channel>
</rss>
