Test that sshfs can establish the requisite connection:\nsudo mkdir \/mnt\/sshfs_temp\nsudo sshfs remoteuser@remotehost: \/mnt\/sshfs_temp\nsudo fusermount -u \/mnt\/sshfs_temp\nsudo rmdir \/mnt\/sshfs_temp<\/pre>\nNote that the :<\/code> is required after the host to specify the remote directory. (:<\/code> alone means the remote user’s home. :\/remote\/path<\/code> indicates a remote path.)<\/li>\nAdd the following line to your \/etc\/auto.master<\/code><\/strong> file:\n\/mnt\/ssh<\/strong> \/etc\/auto.sshfs uid=1000<\/strong>,gid=1000<\/strong>,--timeout=30<\/strong>,--ghost<\/pre>\nWhere \/mnt\/ssh<\/strong> is the path you want all ssh automounts to appear in,
\n1000<\/strong> is the UID of the user you want the sshfs mount to belong to (i.e., be writable by),
\n1000<\/strong> is the GID of the user you want the sshfs mount to belong to, and
\n30<\/strong> is the timeout in seconds to keep the FUSE connection alive.<\/li>\nCopy the following into a new file \/etc\/auto.sshfs<\/code><\/strong>:\n#\n# This is an automounter map and it has the following format\n# key [ -mount-options-separated-by-comma ] location\n# Details may be found in the autofs(5) manpage\nremote1 -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs#remoteuser@remotehost1:\nremote2 -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs#remoteuser2@remotehost2:\/remote\/path\n<\/pre>\nThis creates two sshfs mappings (obviously, adding or removing lines creates more or fewer mappings).
\nThe first will be at \/mnt\/ssh\/remote1<\/code>, and map to the home directory of remoteuser<\/code> on the host remotehost1<\/code>.
\nThe second will be at \/mnt\/ssh\/remote2<\/code>, and map to the directory \/remote\/path<\/code> on the host remotehost2<\/code>, with the permissions of the user remoteuser2<\/code>.
\nNote the <\/code> characters to escape #<\/code> and :<\/code><\/strong> These escape characters are what took me two hours to track down: FUSE requires a parameter of the form: sshfs#user@host:directory<\/code>, but autofs treats everything following a #<\/code> as a comment, and the :<\/code> character has a special meaning. These characters must be escaped by a <\/code><\/li>\nRestart autofs to reload the configuration files:\nsudo \/etc\/init.d\/autofs restart<\/pre>\n<\/li>\n
Test it out! As root or the user indicated by uid<\/code> above, run:\nls \/mnt\/ssh\/remote1<\/pre>\nYou should be greeted by the contents of the remote file system. Congratulations!<\/li>\n<\/ol>\n
The Problems<\/h3>\n\n- This exact setup only works for one user due to specifying a uid. This is fine for a home desktop system, but will likely need further work to allow multiple users access to the remote filesystem. Perhaps careful usage of gid could alleviate this problem, though logging into the remote machine as a specific user still represents a security risk.<\/li>\n
- I have not examined the architecture enough since I am only seeking to enable my home desktop system, so I cannot vouch for the security of this setup<\/strong> whatsoever. For example, the use of the allow_other option for FUSE may have security consequences since the mountpoint is created as root (to my understanding, at least).<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"
You want to access a remote file system over SSH. You want to use FUSE SSHFS, and you don’t want to ever have to think about it, so you’re looking for Autofs integration.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[7,8,30],"tags":[],"_links":{"self":[{"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/posts\/249"}],"collection":[{"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":1,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":1671,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/posts\/249\/revisions\/1671"}],"wp:attachment":[{"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mccambridge.org\/blog\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}