Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a way to configure the automounter (either Linux or OSX) with FUSE sshfs so that cd /servers/<server> will automount the correct server with sshfs?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I just replied with an example answer to another question (autofs+sshfs-answer)

Remember! Autofs user by default is root. So get sshfs working with root first.

auto.master line

note! use your own uid and gid and specify your prefered mount point I use /auto/mehtod/address

/auto/sshfs /etc/auto.sshfs uid=1000,gid=1000,--timeout=60,--ghost

auto.sshfs this is a bit more generic than just one mount

#!/bin/bash

# Shell script that acccepts one argument, namely userid@server
# env >> /tmp/env_check
# whoami >> /tmp/env_check

key=$1
USER='your_local_user_used_for_ssh_identity_file'
REMOTEDEFAULT='default_to_this_user_otherwise_root'
key=${key//[: #]/}

# add user
[[ ! "$key" =~ "@" ]] && key="${REMOTEDEFAULT}@${key}"

case $key in
   ${REMOTEDEFAULT}@.Trash*)
      exit 1;;
   *)
      (
      echo "-fstype=fuse,idmap=user,rw,nodev,nonempty,transform_symlinks,noatime,allow_other,IdentityFile=/home/${USER}/.ssh/id_dsa,max_read=65536\\"
      echo -e "\t /uhome :sshfs\#$key\:\\"
      echo -e "\t /tmp :sshfs\#$key\:\/tmp\/\\"
      echo -e "\t /rootfs :sshfs\#$key\:\/")
esac

## this is a bit more complex. It creates subfolders to autofs-mount/remotename
## /uhome  = your remote homedirectory
## /rootfs = remote root '/'
## /tmp    = remote tmp # same as /roots/tmp

then link to folder you want to access ln -s /auto/sshfs/userid@my.remote.example.com/uhome/ remote-home

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.