使用SSHFS挂载远端目录

  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 [email protected]:/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 [email protected]
    $ # 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#[email protected]:/home/users /root/sshfsExample fuse defaults 0 0
    $ I have not tried it hope the above commands work well

猜你喜欢

转载自blog.csdn.net/solinger/article/details/85258071
今日推荐