Table of Contents

Mounting SDF Folders on a NetBSD Local Machine via mount_psshfs(8)

What is mount_psshfs(8) ?

NetBSD has its own implementation of FUSE 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.

Creating basic psshfs mounts

You'll likely need root permissions to run mount_psshfs(8); examples below assume the sudo(8) tool is installed.

ex.1) create a basic read-only mount of an SDF user's $HOME directory under /mnt

sudo mount_psshfs -o ro sdf_user@freeshell.org /mnt
sdf_user@freeshell.org's password: ********

Use the mount(8) command to see what the mount looks like:

mount -t puffs\|psshfs
sdf_user@freeshell.org on /mnt type puffs|psshfs (read-only)

ex.2) mount sdf_user@freeshell.org/gopher read-write with compression and public key authentication

sudo mount_psshfs -O Compression=yes -O IdentityFile=/home/local_user/.ssh/id_rsa sdf_user@freeshell.org:gopher /mnt

For help setting up public key authentication see the SSH-SDF tutorial.

ex.3) put the above in /etc/fstab; mount to local /puffsmnt

  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

Fixing the displayed file permissions with mount_umap(8)

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 sub-tree 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:

ex.5) mount /puffsmnt to ~local_user/puffy with local_user:users permissions

First, we find who's who on local system (note: UID/GID are fields 3 & 4):

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

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:

sudoedit /uid-mapfile
1
1000 012345
sudoedit /gid-mapfile
1
100 550

Now we make the ~local_user/puffy dir and mount the umap sub-tree of /puffsmnt on it:

mkdir ~local_user/puffy
sudo mount_umap -o nocoredump -g /gid-mapfile -u /uid-mapfile /puffsmnt ~local_user/puffy

Use mount(8) and ls(1) to see what the umap mount looks like:

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

Alternately, you can add the umap mount to /etc/fstab:

sudoedit /etc/fstab
...
/puffsmnt /home/local_user/puffy umap rw,noauto,nocoredump,-g=/gid-mapfile,-u=/uid-mapfile
sudo mount ~local_user/puffy

Unmounting umap and psshfs mounts

Unmount umap and psshfs mounts in the usual way with umount(8), but do it in reverse order:

sudo umount ~local_user/puffy
sudo umount /puffsmnt

References: