Linux上通過SSH掛載遠(yuǎn)程文件系統(tǒng)方法詳解
SSHFS的特點(diǎn):
基于FUSE(Linux的最佳用戶空間文件系統(tǒng)框架)
多線程:在服務(wù)器上可以有多個(gè)請求
允許大讀?。ㄗ畲?4k)
緩存目錄內(nèi)容
步驟1:安裝fuse-sshfs
對于centos/rhel用戶,fuse sshfs在epel repository下可用,因此請確保在系統(tǒng)中安裝了epel repository?,F(xiàn)在執(zhí)行以下命令安裝它
在CENTOS/RHELL上:
#yum install fuse-sshfs
在Ubuntu和Dabian上:
$ sudo apt-get update $ sudo apt-get install sshfs
步驟2:裝載遠(yuǎn)程目錄
讓我們使用sshfs掛載遠(yuǎn)程服務(wù)器目錄,確保遠(yuǎn)程系統(tǒng)運(yùn)行的ssh服務(wù)器與系統(tǒng)的ssh連接正確。
首先創(chuàng)建裝入點(diǎn)
# mkdir /mntssh
讓我們掛載遠(yuǎn)程目錄。對于本例,我們將把/home/remoteuser目錄從192.168.1.12(remote.example.com)系統(tǒng)安裝到本地系統(tǒng)。
# 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)? yes remoteuser@remote.example.com's password:
步驟3:驗(yàn)證安裝
在本地掛載點(diǎn)上掛載遠(yuǎn)程文件系統(tǒng)后,通過運(yùn)行mount命令進(jìn)行驗(yàn)證。
# 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)
同樣導(dǎo)航到你的掛載點(diǎn),將從遠(yuǎn)程系統(tǒng)中看到文件
# cd /mntssh # ls
步驟4:在系統(tǒng)引導(dǎo)時(shí)掛載目錄
如果要在每次系統(tǒng)重新引導(dǎo)時(shí)自動掛載遠(yuǎn)程文件系統(tǒng),請?jiān)? etc / fstab文件中添加以下條目。確保在遠(yuǎn)程和本地系統(tǒng)之間安裝了基于密鑰的ssh。
remoteuser@remote.example.com:/home/remoteuser /mntssh fuse.sshfs defaults 0 0
步驟5:卸載目錄
如果您的工作結(jié)束并且您不再需要已安裝的目錄,則只需使用以下命令卸載。
#umount / mntssh
相關(guān)文章
Linux系統(tǒng)擴(kuò)容根目錄磁盤空間的操作方法
這篇文章主要介紹了Linux系統(tǒng)擴(kuò)容根目錄磁盤空間的操作方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-07-07linux?和?dockerfile?中配置環(huán)境變量的方式總結(jié)
要熟悉?dockerfile?配置?linux?的知識不能少,所以本文將給大家總結(jié)?linux?與?dockerfile?中各種環(huán)境變量,需要的朋友可以參考下2023-07-07Linux centos下設(shè)置定時(shí)備份任務(wù)的方法步驟
這篇文章主要介紹了Linux centos下設(shè)置定時(shí)備份任務(wù)的方法步驟,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01