如何使用sshfs挂载另一台PC的文件

我的环境是这样:

一台4G内存的MacBook,一台16G内存的Thinkpad。

我的devstack需要8G内存,放在Thinkpad上,然后我需要把虚拟机(devstack)中的/opt/stack文件夹挂载在我的MacBook上。于是就想到了sshfs。

sshfs官网介绍是这样说的:

SSH is a secure protocol for communicating between machines. SSHFS is a tool that uses SSH to enable mounting of a remote filesystem on a local machine; the network is (mostly) transparent to the user. Because SSHFS authenticates connections, you can be sure that only those who should have access to remote directories can mount them (as long as everything is configured properly). Because SSH encrypts connections, no one can see your files as they are transferred over the network. And because SSHFS is built using FUSE, even your own root user can only see your files by logging in to your account with su.

准备工作(devstack上)

  1. 修改 root 密码
1
sudo passwd root  
  1. 以其他账户登录,通过 sudo nano 修改 /etc/ssh/sshd_config :
1
2
3
xxx@ubuntu14:~$ su - root
Password:
root@ubuntu14:~# vi /etc/ssh/sshd_config
  1. 注释掉 #PermitRootLogin without-password,添加 PermitRootLogin yes
1
2
3
4
5
# Authentication:
LoginGraceTime 120
#PermitRootLogin without-password
PermitRootLogin yes
StrictModes yes
  1. 重启 ssh 服务
1
2
3
4
root@ubuntu14:~# sudo service ssh restart
ssh stop/waiting
ssh start/running, process 1499
root@ubuntu14:~#

Macbook

网站下载
下载:osxfuse-2.7.3.dmg http://osxfuse.github.io/
下载:sshfs-2.5.0.pkg https://github.com/osxfuse/sshfs/releases/
都安装了就搞定了

然后可以在MacBook上执行下面命令进行挂载

1
sshfs root@192.168.51.101:/opt/stack /Users/JianqingJiang/Desktop/Dev/vm_devstack/

取消挂载的命令

1
2
sh-3.2# diskutil umount /Users/JianqingJiang/Desktop/Dev/vm_devstack/
Unmount successful for /Users/JianqingJiang/Desktop/Dev/vm_devstack/

不过我遇到了一个问题:
sshfs挂载好的devstack的/opt/stack文件在Mac图形化界面不显示,在terminal中显示

image

在界面上尝试了各种办法还是不行

image

蒋暕青

蒋暕青
Lots of mountains to climb,lots of enemies to defeat.

OpenStack cinder mutil-attach技术探秘

OpenStack cinder mutil-attach技术探秘 Continue reading

OpenStack octavia简介

Published on July 18, 2018

Openstack Cyborg项目介绍

Published on July 15, 2018