1、安装brew软件安装工具
brew类似于ubuntu的apt-get,centos的yum。
具体安装brew的方式可以百度搜索一下。
2、安装fuse和sshfs
2.1、安装fuse
sshfs依赖于fuse,因此首先安装fuse。当然你可以直接安装sshfs,那样会提示你依赖的fuse不存在,安装会出错。
% brew install fuse
安装过程中会从github上拉取代码,由于网络问题偶尔会出现拉取代码出错,可以多试几次。
安装完成后重启一下你的MacOS。
2.2、安装sshfs
% brew install sshfs
3、挂载
# 首先创建本地目录,用于挂载
mkdir shared
# 挂载远程目录到本地,直行成功后会提示输入密码,输入远程linux用户对应的密码即可
sshfs -C root@192.168.10.12:/home/owner ./shared
# sshfs 命令可以加参数(-o reconnect)用于断线自动重连。
# 例如:sshfs -C -o reconnect root@192.168.10.12:/home/owner ./shared
# 取消挂载
umount ./shared
注意:
直行挂载命令时,由于macos的安全隐私原因会提示错误,提示内容如下:
The system extension required for mounting FUSE volumes could not be loaded.
Please open the Security & Privacy System Preferences pane, go to the General preferences and allow loading system software from developer "Benjamin Fleischer". A restart might be required before the system extension can be loaded.
Then try mounting the volume again.
解决方法:
打开【系统偏好设置】,点击【安全性于隐私】,选择第一个标签栏【通用】,点击左下角的"小锁子"图标,有一个"benjamin Fleischer"的提示并且后边附带一个按钮【允许】,点击这个"允许"按钮即可。
然后重新直行挂载命令即可成功。