【Linux sshfs】sshfs将远程目录挂载到本地目录

1、安装epel的yum源,安装fuse、sshfs
#yum install -y fuse sshfs

2、sshfs自动登录,生成密钥
#ssh-keygen -t rsa 
#cat .ssh/id_rsa.pub | ssh [remote_user]@[remote_server] "cat - >>.ssh/authorized_keys"

注:无密码ssh登录的基本原理是,在本地的root用户下,用ssh-keygen命令生成一对密钥,然后将其中的公钥,追加到远程服务器的authorized_keys文件中即可。密钥对只对本地的生成用户有效,其他用户需要重新生成并添加。

3、挂载远程 ssh 文件系统

#sshfs gintama@172.31.30.57:/data/jdsdk/runtime/ /data/app_data/sdk/redis/

sshfs 用户名@远程主机IP:远程主机路径 本地挂载点


sshfs [user@]host:[dir] mountpoint [options]

前面和ssh命令一样,mountpoint是挂载点
options重点关注下:
-C 压缩,或者-o compression=yes
-o reconnect 自动重连
-o transform_symlinks 表示转换绝对链接符号为相对链接符号
-o follow_symlinks 沿用服务器上的链接符号
-o cache=yes
-o allow_other 这个参数最重要,必须写,否则任何文件都是Permission Deny


4、查看挂载情况,卸载挂载点
#mount
查看挂载情况
0213f3e4c0b1dd829b64ef0b3012ac8288c9d062
#umount mount_point
#fusermount -u mount_point
卸载挂载点

5、开机自动挂载
#sudo sed -i '$a sshfs#gintama@172.31.30.57:/data/jdsdk/runtime/ /data/app_data/sdk/redis/ fuse defaults,auto,allow_other 0 0' /etc/fstab
#sudo sed -i '$a\sshfs#gintama@172.31.29.97:/data/jdsdk/runtime/ /data/app_data/sdk/game/ fuse defaults,auto,allow_other 0 0' /etc/fstab 
3b02544953e2331a1af944e4adff6ef5e99fd155

6、fuse: failed to exec fusermount: Permission denied错误解决
提示错误:
fuse: failed to exec fusermount: Permission denied
fuse failed. Common problems:
- fuse kernel module not installed (modprobe fuse)
- invalid options -- see usage message
 
   

 
  
 
     








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值