当前位置: 首页 > 工具软件 > sshfs > 使用案例 >

使用SSHFS挂载远端目录

吕霖
2023-12-01
  1. 安装sshfs包
    $ # if your system is just the 'centos', you just need to run yum
    $ sudo yum install -y sshfs

     

  2. 将用户增加到fuse组
    $ # If the current user is not in fuse, when we try to mount, you would meet 'permission' error.
    $ # If the 'fuse' group does not exist, we need to create one group 'fuse' and then add $ sudo usermod -a -G fuse wlin
    usermod: group 'fuse' does not exist
    $ sudo groupadd fuse
    $ sudo usermod -a -G fuse wlin
    

     

  3. 实施挂载
    $ # The 'mountpoint' can be anywhere not just under /mnt dir
    $ # Now let me mount one remote file to the local dir
    $ mkdir ROR_Blog_testing
    $ cd ROR_Blog_testing
    $ sshfs wlin@10.66.137.45:/home/wlin/ROR_Blog . 
  4. 停止挂载

    $ unmount ROR_Blog_testing

     

  5. 若希望启动自动挂载

    $ # Make sure you can ssh the remote host without passwords. If you cannot, try the following steps
    $ ssh-keygen -t rsa
    $ ssh-copy-id -i ~/.ssh/id_rsa.pub wlin@10.66.136.45
    $ # After you can ssh the remote host without passwords, you can edit the fstab as follows
    $ # make sure the mount point is one persistent file system
    $ sshfs#wlin@10.66.136.45:/home/users /root/sshfsExample fuse defaults 0 0
    $ I have not tried it hope the above commands work well

     

 类似资料: