您的位置:首页 > 其它

简单好用的sshfs -- 通过ssh映射远程路径(转)

2014-05-26 10:15 591 查看
最近习惯性访问N个Linux机器,在不同机器间跳来跳去,很是麻烦,最终,找到了sshfs,可以把远程目录直接映射到本地,无需修改远程机器的设置,仅要求有ssh连接的权限(ssh都没有的话,还能干啥?!~!)

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

安装:

#如果是ubuntu
apt-getinstallsshfs
#如果是Fedore
yuminstallfuse-sshfs
#如果是CentOS,貌似只能自己安装了
wgethttp://nchc.dl.sourceforge.net/project/fuse/sshfs-fuse/2.4/sshfs-fuse-2.4.tar.gztarxvfsshfs-fuse-2.4.tar.gz
cdsshfs-fuse-2.4./configure
#如果缺glib2什么的,就自行装上
makeinstall

先看看选项:

generaloptions:-oopt,[opt...]mountoptions
-h--helpprinthelp
-V--versionprintversion

SSHFSoptions:-pPORTequivalentto'-oport=PORT'-Cequivalentto'-ocompression=yes'#启用压缩,建议配上-Fssh_configfilespecifiesalternativesshconfigurationfile#使用非默认的ssh配置文件-1equivalentto'-ossh_protocol=1'#不要用啊-oreconnectreconnecttoserver#自动重连-odelay_connectdelayconnectiontoserver
-osshfs_syncsynchronouswrites
-ono_readaheadsynchronousreads(nospeculativereadahead)#提前预读-osshfs_debugprintsomedebugginginformation
-ocache=BOOLenablecaching{yes,no}(default:yes)#能缓存目录结构之类的信息-ocache_timeout=Nsetstimeoutforcachesinseconds(default:20)-ocache_X_timeout=Nsetstimeoutfor{stat,dir,link}cache
-oworkaround=LISTcolonseparatedlistofworkarounds
nonenoworkaroundsenabled
allallworkaroundsenabled
[no]renamefixrenamingtoexistingfile(default:off)[no]nodelaysrvsetnodelaytcpflaginsshd(default:off)[no]truncatefixtruncateforoldservers(default:off)[no]buflimitfixbufferfillupbuginserver(default:on)-oidmap=TYPEuser/groupIDmapping,possibletypesare:#文件权限uid/gid映射关系
nonenotranslationoftheIDspace(default)
useronlytranslateUIDofconnectinguser
-ossh_command=CMDexecuteCMDinsteadof'ssh'-ossh_protocol=Nsshprotocoltouse(default:2)#肯定要2的-osftp_server=SERVpathtosftpserverorsubsystem(default:sftp)-odirectport=PORTdirectlyconnecttoPORTbypassingssh
-otransform_symlinkstransformabsolutesymlinkstorelative
-ofollow_symlinksfollowsymlinksontheserver
-ono_check_rootdon'tcheckforexistenceof'dir'onserver
-opassword_stdinreadpasswordfromstdin(onlyforpam_mount)
-oSSHOPT=VALsshoptions(seemanssh_config)

Moduleoptions:

[subdir]
-osubdir=DIRprependthisdirectorytoallpaths(mandatory)
-o[no]rellinkstransformabsolutesymlinkstorelative

[iconv]
#字符集转换,对我这种UTF8控,默认已经是最好的
-ofrom_code=CHARSEToriginalencodingoffilenames(default:UTF-8)
-oto_code=CHARSETnewencodingofthefilenames(default:UTF-8)

实际使用:

挂载(如果配上sshkey就可以完全自动化了):
sshfsroot@192.168.9.109:/opt/opt/s109
卸载:
fusermount-u/opt/s109


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: