您的位置:首页 > 运维架构 > Linux

使用sshfs挂载远程主机文件到linux

2016-08-04 17:42 731 查看
场景:

将远程Windows系统主机上的文件夹挂载到本地linux主机指定目录下。

Windows系统主机上的文件夹:d:\Work\workspace

Windows系统主机用户:host_name

Windows系统主机IP:host_ip

linux主机指定目录:/mnt/win_workspace/

1、创建挂载点,修改权限

yang@master$ sudo mkdir win_workspace
yang@master:$ sudo chgrp -R yang win_workspace/
yang@master:$ sudo chown -R yang win_workspace/


2、使用sshfs挂载

yang@master:~$ sshfs host_name@host_ip:/d:\Work\workspace /mnt/win_workspace/


3、然而報错

fuse: bad mount point `/mnt/win_workspace/': Transport endpoint is not connected


yang@master:~$ ll /mnt/
ls: cannot access '/mnt/win_workspace': Transport endpoint is not connected
total 8
drwxr-xr-x  3 root root 4096 Aug  4 16:59 ./
drwxr-xr-x 24 root root 4096 Jul 29 09:39 ../
d?????????  ? ?    ?       ?            ? win_workspace/


看到很多????

4、解决方法[1]

yang@master:~$ sudo umount -l /mnt/win_workspace
yang@master:~$ ll /mnt/
total 12
drwxr-xr-x  3 root root 4096 Aug  4 16:59 ./
drwxr-xr-x 24 root root 4096 Jul 29 09:39 ../
drwxr-xr-x  2 yang yang 4096 Aug  4 16:59 win_workspace/


可以看到,之前出现的很多???消失了。

5、修改文件/etc/fuse.conf

yang@master:~$ vi /etc/fuse.conf


为了使用user_allow_other,需要将文件的最后一行user_allow_other前面的注释符号#去掉,修改成如下。

# /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE)

# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#mount_max = 1000

# Allow non-root users to specify the allow_other or allow_root mount options.
user_allow_other


6、使用sshfs的额外配置项连接

yang@master:~$ sudo sshfs -d -o allow_other -o reconnect -o ServerAliveInterval=15 host_name@host_ip:/d:/Work/workspace/ /mnt/win_workspace/ -p 22 -C
FUSE library version: 2.9.4
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0


接下来正常的话,需要输入密码,然后OK了。

默认windows的22号端口是关闭的,我是安装了Bitvise SSH Server.

参考文献:

[1] http://slopjong.de/2013/04/26/sshfs-transport-endpoint-is-not-connected/comment-page-1/#comment-219607
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux windows