145 lines
4.2 KiB
HTML
145 lines
4.2 KiB
HTML
<style type="text/css">
|
|
p {
|
|
margin-right:10em;
|
|
}
|
|
pre {
|
|
margin-left: 2em;
|
|
margin-right: 2em;
|
|
background-color: #ddd; padding: 10px;
|
|
color: green;
|
|
}
|
|
</style>
|
|
|
|
<h2>Mounting SDF Folders on a NetBSD Local Machine via mount_psshfs(8)</h2>
|
|
|
|
<hr>
|
|
|
|
<h3>What is mount_psshfs(8) ?</h3>
|
|
<p><a href="http://netbsd.org/">NetBSD</a> has its own implementation of
|
|
<a href="http://fuse.sourceforge.net/">FUSE</a> called ReFUSE(3); mount_psshfs(8) creates sshfs mounts via
|
|
PUFFS(4) (Pass-to-Userspace Framework File System). See the respective
|
|
manpages and References section for details.</p>
|
|
|
|
<h3>Creating basic psshfs mounts:</h3>
|
|
<p>You'll likely need root permissions to run mount_psshfs(8); examples
|
|
below assume the sudo(8) tool is installed.</p>
|
|
|
|
<p><b>ex.1)</b> create a basic read-only mount of an SDF user's $HOME directory under /mnt:</p>
|
|
|
|
<pre>
|
|
sudo mount_psshfs -o ro sdf_user@freeshell.org /mnt
|
|
sdf_user@freeshell.org's password: ********
|
|
</pre>
|
|
|
|
<p>Use the mount(8) command to see what the mount looks like:</p>
|
|
|
|
<pre>
|
|
mount -t puffs\|psshfs
|
|
sdf_user@freeshell.org on /mnt type puffs|psshfs (read-only)
|
|
</pre>
|
|
|
|
<p><b>ex.2)</b> mount sdf_user@freeshell.org/gopher read-write with compression
|
|
and public key authentication:</p>
|
|
|
|
<pre>
|
|
sudo mount_psshfs -O Compression=yes -O IdentityFile=/home/local_user/.ssh/id_rsa sdf_user@freeshell.org:gopher /mnt
|
|
</pre>
|
|
|
|
<p>For help setting up public key authentication see the <a
|
|
href="http://sdf.org/?tutorials/SSH-SDF#public_key">SSH-SDF</a>
|
|
tutorial.</p>
|
|
|
|
<p><b>ex.3)</b> put the above in /etc/fstab; mount to local /puffsmnt:</p>
|
|
|
|
<pre>
|
|
sudo mkdir /puffsmnt
|
|
|
|
sudoedit /etc/fstab
|
|
...
|
|
# psshfs PUFFS mount of gopher dir on sdf_user@.sdf.org
|
|
sdf_user@sdf.org:/ftp/pub/users/sdf_user /puffsmnt psshfs rw,noauto,-O=BatchMode=yes,-O=IdentityFile=$HOME/.ssh/id_rsa,-t=-1
|
|
|
|
sudo mount /puffsmnt
|
|
</pre>
|
|
|
|
<h3>Fixing the displayed file permissions with <b>mount_umap(8)</b></h3>
|
|
<p>With the above examples you'll probably notice that the UID:GID values
|
|
for the psshfs mount are either numerical values or otherwise not what
|
|
you might expect; this is because your local system doesn't have mappings
|
|
for the remote UID:GID (what you're seeing) to the local system. If you
|
|
like, you can create a local <i>sub-tree</i> of the puffs mount with
|
|
re-mapped UID:GID values using mount_umap(8). The following example
|
|
creates two mapfiles (must be root owned) and a new mount point under the
|
|
local user's $HOME directory and mounts /puffsmnt from ex.4 above:
|
|
|
|
<p><b>ex.5)</b> mount /puffsmnt to ~local_user/puffy with local_user:users permissions:</p>
|
|
|
|
<p>First, we find who's who on local system (note: UID/GID are fields 3 & 4):</p>
|
|
|
|
<pre>
|
|
ls -dnl /puffsmnt
|
|
drwxr-xr-x 42 012345 550 512 Aug 31 2011 puffsmnt
|
|
|
|
grep local_user /etc/passwd
|
|
local_user:*:1000:100:Loco User ,Seattle,WA ,:/home/local_user:/bin/ksh
|
|
</pre>
|
|
|
|
<p>From above we see that we need to re-map local UID 1000 to 012345,
|
|
and local GID 100 to 550. We just have one remapping each so the
|
|
uid-mapfile and gid-mapfile files get made like so:</p>
|
|
|
|
<pre>
|
|
sudoedit /uid-mapfile
|
|
1
|
|
1000 012345
|
|
|
|
sudoedit /gid-mapfile
|
|
1
|
|
100 550
|
|
</pre>
|
|
|
|
<p>Now we make the ~local_user/puffy dir and mount the umap sub-tree of /puffsmnt on it:</p>
|
|
|
|
<pre>
|
|
mkdir ~local_user/puffy
|
|
sudo mount_umap -o nocoredump -g /gid-mapfile -u /uid-mapfile /puffsmnt ~local_user/puffy
|
|
</pre>
|
|
|
|
<p>Use mount(8) and ls(1) to see what the umap mount looks like:</p>
|
|
|
|
<pre>
|
|
mount -t umap
|
|
/puffsmnt on /home/local_user/puffy type umap (nocoredump)
|
|
|
|
ls -dl ~local_user/puffy
|
|
drwxr-xr-x 101 local_user users 512 Dec 6 2010 puffy
|
|
</pre>
|
|
|
|
<p>Alternately, you can add the umap mount to /etc/fstab:</p>
|
|
|
|
<pre>
|
|
sudoedit /etc/fstab
|
|
...
|
|
/puffsmnt /home/local_user/puffy umap rw,noauto,nocoredump,-g=/gid-mapfile,-u=/uid-mapfile
|
|
|
|
sudo mount ~local_user/puffy
|
|
</pre>
|
|
|
|
<h3>Unmounting umap and psshfs mounts:</h3>
|
|
<p>Unmount umap and psshfs mounts in the usual way with umount(8), but do it in <em>reverse</em> order:</p>
|
|
|
|
<pre>
|
|
sudo umount ~local_user/puffy
|
|
sudo umount /puffsmnt
|
|
</pre>
|
|
|
|
<h3>References:</h3>
|
|
<ul>
|
|
<li><a href="http://www.netbsd.org/docs/puffs/">NetBSD PUFFS documentation</a>
|
|
<li><a href="http://man.netbsd.org/">NetBSD manpages</a>
|
|
</ul>
|
|
|
|
<br>
|
|
|
|
<cite>$Id: psshfs.html,v 1.2 2011/12/13 05:53:48 jgw Exp $</cite>
|