sshfs挂载与ssh无密码登录

来源:互联网 发布:淘宝运营承包怎么收费 编辑:程序博客网 时间:2024/06/06 07:35

最近架设了一台外网服务器,专门用于bt、电驴的下载。原先使用samba服务进行文件访问,后来发现,Linux下访问samba服务太慢,百兆链路,只有几百KB/s的速度。经推荐,开始使用sshfs,速度很快,速度经常能上10MB/s。
安装

emerge sshfs-fuse

使用
mkdir mountpoint
sshfs [remote_user]@[remote_server]:[remote_directory] [mountpoint] -o allow_other

也可以自动挂载,主要分两步
1、设置对远程服务器的无密码登录
image
如图所示,无密码ssh登录的基本原理是,在本地的root用户下,用ssh-keygen命令生成一对密钥,然后将其中的公钥,追加到远程服务器的authorized_keys文件中即可。密钥对只对本地的生成用户有效,其他用户需要重新生成并添加。命令如下:
ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh [remote_user]@[remote_server] "cat - >>.ssh/authorized_keys"

2、修改fstab
如下添加一行:
sshfs#[remote_user]@[remote_server]:[remote_directory] [mountpoint] [mountpoint] fuse allow_other 0 0

参考文档:
《Linux实现无密码登录》
番外篇:
windows的sshfs
windows的sshfs是以dokan library+dokan sshfs的形式实现的。
访问这里:Dokan:http://dolan-dev.net/en/download/
依次下载安装:
  1. Microsoft Visual C++ 2005 SP1 Redistributable Package
  2. dokan-0.5.2
  3. dokan-sshfs-0.2.0.1226
  4. dokan-sshfs-for-dokan-050.zip

即可