在远程机器(Ubuntu)上安装本地目录(Mac)



我知道我们可以使用sshfs在本地机器上装载远程机器目录,但是,反过来可能吗。我想在本地系统上编辑这些文件,不希望它们永久驻留在远程服务器上。

我试过这个(https://github.com/agirorn/mount-on)似乎不起作用。

我想安装一个本地目录,如:

/Users/username/sshfs_share_folder

到我可以ssh访问的远程机器上,例如:

/home/username/shared_folder

假设本地机器位于NAT之后,并且不能从远程机器直接ssh到本地机器,则使用远程端口转发在本地机器上运行反向ssh隧道。

# on local machine
ssh -R 2222:localhost:22 <remote-user>@<remote-addr>

现在,在远程机器上,您可以使用sshfs从本地机器装载一个目录,方法是将其指向localhost:2222,localhost:2222在内部将请求隧道传输到端口22的本地机器。

# on remote machine
sshfs -p 2222 <local-user>@localhost:<local-dir> <remote-dir>

最新更新