使用 SSHFS 挂载远程的文件系统

Posted on Posted in linux

**安装**

  1. # yum install sshfs  
  2. # dnf install sshfs              【在 Fedora 22+ 发行版上】  
  3. $ sudo apt-get install sshfs     【基于 Debian/Ubuntu 的系统】  

**挂载**

  1. # sshfs tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint  
  2. $ sudo sshfs -o allow_other tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint      【基于 Debian/Ubuntu 的系统】  

> 基于 SSH 密钥授权

  1. # sshfs -o IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint  
  2. $ sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint     【基于 Debian/Ubuntu 的系统】  

**永久挂载远程文件系统**

  1. # vi /etc/fstab  
  2. $ sudo vi /etc/fstab     【基于 Debian/Ubuntu 的系统】       
  3.   
  4. sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs defaults 0 0  
  5. # 或基于密钥  
  6. sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0  
  7.   
  8. # mount -a  
  9. $ sudo mount -a   【基于 Debian/Ubuntu 的系统】  

**卸载远程的文件系统**

  1. # umount /mnt/tecmint  

参考 https://linux.cn/article-7855-1.html

Leave a Reply

Your email address will not be published. Required fields are marked *

four × 1 =