#!/bin/bash # Put this in /etc/autofs or just /etc depending on where your distribution # places auto.master. If you are doing per-user setups for this, you might # name it to auto.ssh_username # Either way, you will need to add a line for it to auto.master, such as # /home/user/ssh /etc/autofs/auto.ssh_user # This can be restricted to a particular user by adding something like # uid=1000,gid=1000,umask=077 OPTS="-fstype=fuse,allow_other" # To set this up to use a non-root user's ssh keys instead of root's, # create a script that runs ssh under 'sudo -H -i -u user', substitute # the correct username in place of 'user', and uncomment this line #OPTS="-fstype=fuse,allow_other,ssh_command=/usr/local/bin/sudo_ssh_user" #TODO: see if some way can be found to put a more complex expression for # ssh_command so that an external script is not necessary # Allow for connections to ssh servers on alternate ports # If we are given input of the from # example.com:4000 # then set the port=4000 option HOST="${1}" COLONPOS=`expr index "${HOST}" :` if [[ $COLONPOS > 0 ]] then OPTS="${OPTS},port=${HOST:$COLONPOS}" HOST="${HOST:0:$[$COLONPOS - 1]}" fi # Output in a format pleasing to autofs echo -e "${OPTS}" "\t/\t" "sshfs\#"${HOST}:/ #TODO remove bashisms from this script