Ubuntu安装sshfs

最近公司业务需要需要在客户服务器安装sshfs

1. 首先更换国内阿里云apt源
1
vi /etc/apt/sources.list

替换以下内容

1
2
3
4
5
6
7
8
9
10
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

替换后先更新源

1
sudo apt-get update
2. 安装sshfs,不出意外几秒钟就安装完毕
1
apt-get install sshfs
3. 挂载服务器之间的目录

这里我需要将内网的主服务器目录 /www/wwwroot/default/data 挂载到各个子服务器的 /www/wwwroot/default/data (需要提前建立好)

使用以下命令

1
2
#sshfs -p 端口 用户@ip:被挂载目录 目标挂载目录 -o allow_other
sshfs -p 22222 root@192.168.0.20:/www/wwwroot/default/data /www/wwwroot/default/data -o allow_other

提示输入用户密码,输入完成后就可以了