Linux上通过SSH挂载远程文件系统方法详解

(编辑:jimmy 日期: 2024/9/21 浏览:2)

SSHFS的特点:

基于FUSE(Linux的最佳用户空间文件系统框架)

多线程:在服务器上可以有多个请求

允许大读取(最大64k)

缓存目录内容

步骤1:安装fuse-sshfs

对于centos/rhel用户,fuse sshfs在epel repository下可用,因此请确保在系统中安装了epel repository。现在执行以下命令安装它

在CENTOS/RHELL上:

#yum install fuse-sshfs

在Ubuntu和Dabian上:

$ sudo apt-get update

$ sudo apt-get install sshfs

步骤2:装载远程目录

让我们使用sshfs挂载远程服务器目录,确保远程系统运行的ssh服务器与系统的ssh连接正确。

首先创建装入点

# mkdir /mntssh

让我们挂载远程目录。对于本例,我们将把/home/remoteuser目录从192.168.1.12(remote.example.com)系统安装到本地系统。

# sshfs laitkor@remote.example.com:/home/remoteuser /opt/mntssh

样本输出

The authenticity of host 'remote.example.com (192.168.1.12)' can't be established.

RSA key fingerprint is 77:85:9e:ff:de:2a:ef:49:68:09:9b:dc:f0:f3:09:07.

Are you sure you want to continue connecting (yes/no)"htmlcode">
# mount

 

/dev/mapper/vg_svr1-lv_root on / type ext4 (rw)

proc on /proc type proc (rw)

sysfs on /sys type sysfs (rw)

devpts on /dev/pts type devpts (rw,gid=5,mode=620)

tmpfs on /dev/shm type tmpfs (rw)

/dev/sda1 on /boot type ext4 (rw)remoteuser@remote.example.com:/home/remoteuser on /mntssh type fuse.sshfs (rw,nosuid,nodev)

同样导航到你的挂载点,将从远程系统中看到文件

# cd /mntssh

# ls

步骤4:在系统引导时挂载目录

如果要在每次系统重新引导时自动挂载远程文件系统,请在/ etc / fstab文件中添加以下条目。确保在远程和本地系统之间安装了基于密钥的ssh。

remoteuser@remote.example.com:/home/remoteuser /mntssh fuse.sshfs defaults 0 0

步骤5:卸载目录

如果您的工作结束并且您不再需要已安装的目录,则只需使用以下命令卸载。

#umount / mntssh

一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。