简单好用的sshfs — 通过ssh映射远程路径

6 篇文章 0 订阅
3 篇文章 0 订阅
来自[url]http://wendal.net/457.html[/url]

最近习惯性访问N个Linux机器,在不同机器间跳来跳去,很是麻烦,最终,找到了sshfs,可以把远程目录直接映射到本地,无需修改远程机器的设置,仅要求有ssh连接的权限

官网地址: [url]http://fuse.sourceforge.net/sshfs.html[/url]

安装:

#如果是ubuntu
apt-get install sshfs
#如果是Fedore
yum install fuse-sshfs
#如果是CentOS,貌似只能自己安装了
wget http://nchc.dl.sourceforge.net/project/fuse/sshfs-fuse/2.4/sshfs-fuse-2.4.tar.gz
tar xvf sshfs-fuse-2.4.tar.gz
cd sshfs-fuse-2.4
./configure
#如果缺glib2什么的,就自行装上
make install


先看看选项:


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 #使用非默认的ssh配置文件
-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 sshd (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: #文件权限uid/gid映射关系
none no translation of the ID space (default)
user only translate UID of connecting user
-o ssh_command=CMD execute CMD instead of 'ssh'
-o ssh_protocol=N ssh protocol to use (default: 2) #肯定要2的
-o sftp_server=SERV path to sftp server or subsystem (default: sftp)
-o directport=PORT directly connect to PORT bypassing ssh
-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)

Module options:

[subdir]
-o subdir=DIR prepend this directory to all paths (mandatory)
-o [no]rellinks transform absolute symlinks to relative

[iconv]
#字符集转换,对我这种UTF8控,默认已经是最好的
-o from_code=CHARSET original encoding of file names (default: UTF-8)
-o to_code=CHARSET new encoding of the file names (default: UTF-8)


实际使用:


挂载(如果配上ssh key就可以完全自动化了):
sshfs root@192.168.9.109:/opt /opt/s109
卸载:
fusermount -u /opt/s109
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值