sshfs
filesystem client based on ssh
Synopsis
mounting
sshfs [user@]host:[dir]
mountpoint [options]
unmounting
fusermount -u mountpoint
add an example, a script, a trick and tips
examples
source
Use a device over SSH?
Linux/UNIX are not Plan 9. "Everything is a file" doesn't mean
that they're all the same sort of files. FIFOs and device nodes
being prime examples.
No, you cannot do it this way. My recommendation would be to use
a virtual writer (celebron writes to an image, .iso or other) and
pipe that to cdrecord over ssh.
source
Can't access folders mounted by sshfs after sleep (or when connection lost)
I suffer the same problem in Ubuntu Linux. What I do after
resume:
$ killall -9 sshfs
Then, umount
$ fusermount -u ~/far_projects
and mount again the remote filesystem.
$ sshfs -o idmap=user youruser@server:/projects ~/far_projects
source
What are some options for connecting one Linux host's filesystem to the other?
This started as a comment, but got a bit out of hand...
Services like NFS & Samba are analogous to simple file sharing in
Windows:
- easy to setup,
- tend to be resource hogs and because they are general purpose
file system access protocols,
- they don't excel at the types of situations you describe:
flaky / intermittent connections & moving tens of thousands of
files.
For your monitoring & updating, I would use rsync, not nfs or smb...
You may still want to use samba or nfs for simple file sharing,
browsing, etc. It gets easier & better with (nearly) every ubuntu
release. Start by right-clicking the folder you want to share,
and select Share Folder to get started. There is a gnome bug in 10.04 that doesn't offer to
install needed packages, but it's being worked on.
source
faster way to mount a remote file system than sshfs?
sshfs is using the SSH file transfer protocol, which means
encryption.
If you just mount via NFS, it's of course faster, because not
encrypted.
are you trying to mount volumes on the same network? then
use NFS.
source
scp/sshfs on a remote 'not direct acessable' machine
What OS are you and your destination running?
If it's Linux, then the Zmodem protocol is perfect for what you
are trying to do.
source
sshfs: cannot set file timestamp
Judging from http://sourceforge.net/mailarchive/message.php?msg_id=26780130
(FUSE mailing list - basically, what SSHFS implements), you are
experiencing this problem, because filesystem used in
/sshfs/server/some/ does not handle the attributes handler used.
There is no solution whatsoever for SSHFS implementation that you
are using.
EDIT
Sorry, I didn't see that you have "noatime" option set. Why?
Remove it. That should solve the issue here.
source
portmap on debian, can I safely remove it?
If you don't use NFS, yes, it's safe to remove it.
source
sshfs device is busy
Some program is using a file in the filesystem you're trying to
unmount. It could be a file opened for reading or writing, a
current directory, or a few more obscure cases. It could even be
due to a directory on the filesystem being a mount point.
To investigate, run lsof +f -- example
. It will tell
what the process(es) are using the filesystem. Make your own
judgement as to whether to make them close files, kill them, or
defer the unmount operation.
source
Remote file system access issues
I think the problem is sshfs (or using a remote terminal protocol
like SSH as a file access protocol) where every file access needs
to be simulated using shell commands which is extrememly
inefficient.
You should be able to get much better performance with proper
filing protocols like NFS or CIFS. Remember to use a VPN like
kobaltz suggested because these filing protocols aren't very
secure.
source
Running sshfs as user via autofs
Drawing heavily from another
similar question, I've found a solution. It required some
serious experimentation and tweaking, though. Note that this
modified script is now incompatible with mounting from
/etc/fstab
.
/etc/auto.master
/- /etc/auto.sshfs uid=1000,gid=1000,--timeout=30,--ghost
/etc/auto.sshfs
/local/mountpoint -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,workaround=rename,ssh_command=/usr/local/sbin/ssh_user :sshfs\#remoteuser@server\:/remote/path
This needs to be executable, of course:
/usr/local/sbin/ssh_user
#!/bin/bash
# declare arrays for ssh options
declare -a ADD_OPTIONS
declare -a CLEANED_SSH_OPTS
# add options to be automatically added to the ssh command here.
# example
#ADD_OPTIONS=( '-C' )
# empty default
ADD_OPTIONS=( )
# The following options to SSH cause it to open a connection and immediately
# become a background task. This allow this script to open a local socket
# for future invocations of ssh. (use "ControlMaster auto" in ~/.ssh/config)
SOCKET_OPTIONS=( '-fN' )
for OPT in "$@"; do
# Add list of values to be removed from sshfs ssh options. By default, sshfs
# disables X11 forwarding. We're overriding that behavior.
case $OPT in
"-x")
# this and these like this will be removed
;;
"-a")
;;
"-oClearAllForwardings=yes")
;;
*)
# These are ok.. add
NUM=${#CLEANED_SSH_OPTS[@]}
CLEANED_SSH_OPTS[$NUM]="$OPT"
;;
esac
done
# For some reason, I needed to generate strings of the ssh command before
# passing it on as an argument to the 'su' command. It simply would not
# work otherwise.
# Throwing the $SOCKET_OPTIONS in with the rest of the arguments is kind
# of hackish, but it seems to handily override any other specified behavior.
# Establishes an ssh socket if none exists...
SSH_SOCKET_CMD="ssh $SOCKET_OPTIONS ${ADD_OPTIONS[@]} ${CLEANED_SSH_OPTS[@]}"
su localuser -c "$SSH_SOCKET_CMD"
# ...and use that socket to mount the remote host
SSH_SSHFS_CMD="ssh ${ADD_OPTIONS[@]} ${CLEANED_SSH_OPTS[@]}"
exec su localuser -c "$SSH_SSHFS_CMD"
And, in case anyone cares:
~/.ssh/config
Host *
ControlMaster auto
ControlPath /tmp/%u@%l?%r@%h:%p
ServerAliveInterval 10
Compression yes
Host host1 host1.myschool.edu host2 host2.myschool.edu
ForwardX11 yes
Ciphers arcfour256,arcfour128,arcfour,blowfish-cbc
Host host3 host3.myschool.edu
ForwardX11 no
Ciphers arcfour256,arcfour128,arcfour,blowfish-cbc
description
SSHFS (Secure
SHell FileSystem) is a file system for Linux (and other
operating systems with a FUSE implementation, such as Mac OS
X or FreeBSD) capable of operating on files on a remote
computer using just a secure shell login on the remote
computer. On the local computer where the SSHFS is mounted,
the implementation makes use of the FUSE (Filesystem in
Userspace) kernel module. The practical effect of this is
that the end user can seamlessly interact with remote files
being securely served over SSH just as if they were local
files on his/her computer. On the remote computer the SFTP
subsystem of SSH is used.
If host
is a numeric IPv6 address, it needs to be enclosed in square
brackets.
options
general
options:
-o opt,[opt...]
mount options
-h
--help
print help
-V
--version
print version
SSHFS
options:
-p PORT
equivalent to ’-o
port=PORT’
-C
equivalent to ’-o compression=yes’
-F
ssh_configfile
specifies alternative ssh
configuration file
-1
equivalent to ’-o ssh_protocol=1’
-o reconnect
reconnect to server
-o
delay_connect
delay connection to server
-o sshfs_sync
synchronous writes
-o
no_readahead
synchronous reads (no
speculative readahead)
-o sshfs_debug
print some debugging
information
-o cache=BOOL
enable caching {yes,no}
(default: yes)
-o
cache_timeout=N
sets timeout for caches in
seconds (default: 20)
-o
cache_X_timeout=N
sets timeout for
{stat,dir,link} cache
-o
workaround=LIST
colon separated list of
workarounds
none
no workarounds enabled
all
all workarounds enabled
[no]rename
fix renaming to existing file
(default: off)
[no]nodelaysrv
set nodelay tcp flag in ssh
(default: off)
[no]truncate
fix truncate for old servers
(default: off)
[no]buflimit
fix buffer fillup bug in server
(default: on)
-o idmap=TYPE
user/group ID mapping, possible
types are:
none
no translation of the ID space (default)
user
only translate UID of connecting user
file
translate UIDs/GIDs based upon the contents of
uidfile and gidfile
-o
uidfile=FILE
file containing username:uid
mappings for idmap=file
-o
gidfile=FILE
file containing groupname:gid
mappings for idmap=file
-o nomap=TYPE
with idmap=file, how to handle
missing mappings
ignore
don’t do any re-mapping
error
return an error (default)
-o
ssh_command=CMD
execute CMD instead of
’ssh’
-o
ssh_protocol=N
ssh protocol to use (default:
2)
-o
sftp_server=SERV
path to sftp server or
subsystem (default: sftp)
-o
directport=PORT
directly connect to PORT
bypassing ssh -o slave communicate over stdin
and stdout bypassing network
-o
transform_symlinks
transform absolute symlinks to
relative
-o
follow_symlinks
follow symlinks on the
server
-o
no_check_root
don’t check for existence
of ’dir’ on server
-o
password_stdin
read password from stdin (only
for pam_mount!)
-o SSHOPT=VAL
ssh options (see man
ssh_config)
FUSE
options:
-d -o debug
enable debug output (implies
-f)
-f
foreground operation
-s
disable multi-threaded operation
-o allow_other
allow access to other users
-o allow_root
allow access to root
-o nonempty
allow mounts over
non-empty file/dir
-o
default_permissions enable permission checking by kernel
-o fsname=NAME
set filesystem name
-o
subtype=NAME
set filesystem type
-o large_read
issue large read requests (2.4
only)
-o max_read=N
set maximum size of read
requests
-o hard_remove
immediate removal (don’t
hide files)
-o use_ino
let filesystem set inode
numbers
-o readdir_ino
try to fill in d_ino in
readdir
-o direct_io
use direct I/O
-o
kernel_cache
cache files in kernel
-o
[no]auto_cache
enable caching based on
modification times
-o umask=M
set file permissions
(octal)
-o uid=N
set file owner (number)
-o gid=N
set file group (number)
-o
entry_timeout=T
cache timeout for names
(1.0s)
-o
negative_timeout=T
cache timeout for deleted names
(0.0s)
-o
attr_timeout=T
cache timeout for attributes
(1.0s)
-o
ac_attr_timeout=T
auto cache timeout for
attributes (attr_timeout)
-o intr
allow requests to be
interrupted
-o
intr_signal=NUM
signal to send on interrupt
(10)
-o
modules=M1[:M2...]
names of modules to push onto
filesystem stack
-o max_write=N
set maximum size of write
requests
-o
max_readahead=N
set maximum readahead
-o async_read
perform reads asynchronously
(default)
-o sync_read
perform reads synchronously
Module
options:
[subdir]
-o subdir=DIR
prepend this directory to all
paths (mandatory)
-o
[no]rellinksa
transform absolute symlinks to
relative
[iconv]
-o from_code=CHARSET
original encoding of file names
(default: UTF-8)
-o
to_code=CHARSET
new encoding of the file names
(default: ISO-8859-2)
authors
SSHFS has been
written by Miklos Szeredi <miklos[:at:]szeredi[:dot:]hu>.
This man page
was written by Bartosz Fenski <fenio[:at:]debian[:dot:]org> for
the Debian GNU/Linux distribution (but it may be used by
others).