【Linux sshfs】sshfs将远程目录挂载到本地目录
生活随笔
收集整理的這篇文章主要介紹了
【Linux sshfs】sshfs将远程目录挂载到本地目录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、安裝epel的yum源,安裝fuse、sshfs #rpm -Uvh?http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm #yum install -y fuse sshfs
2、sshfs自動登錄,生成密鑰 #ssh-keygen -t rsa?
#cat .ssh/id_rsa.pub | ssh [remote_user]@[remote_server] "cat - >>.ssh/authorized_keys"
注:無密碼ssh登錄的基本原理是,在本地的root用戶下,用ssh-keygen命令生成一對密鑰,然后將其中的公鑰,追加到遠程服務器的authorized_keys文件中即可。密鑰對只對本地的生成用戶有效,其他用戶需要重新生成并添加。
3、掛載遠程 ssh 文件系統
options重點關注下:
-C 壓縮,或者-o compression=yes
-o reconnect 自動重連
-o transform_symlinks 表示轉換絕對鏈接符號為相對鏈接符號
-o follow_symlinks 沿用服務器上的鏈接符號
-o cache=yes -o allow_other 這個參數最重要,必須寫,否則任何文件都是Permission Deny
4、查看掛載情況,卸載掛載點 #mount 查看掛載情況
#umount mount_point 或 #fusermount -u mount_point 卸載掛載點
5、開機自動掛載 #sudo?sed?-i?'$a?sshfs#gintama@172.31.30.57:/data/jdsdk/runtime/?/data/app_data/sdk/redis/?fuse?defaults,auto,allow_other?0?0'?/etc/fstab #sudo?sed?-i?'$a\sshfs#gintama@172.31.29.97:/data/jdsdk/runtime/?/data/app_data/sdk/game/?fuse?defaults,auto,allow_other?0?0'?/etc/fstab?
6、fuse: failed to exec fusermount: Permission denied錯誤解決 提示錯誤: fuse: failed to exec fusermount: Permission denied fuse failed. Common problems: - fuse kernel module not installed (modprobe fuse) - invalid options -- see usage message
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
2、sshfs自動登錄,生成密鑰 #ssh-keygen -t rsa?
#cat .ssh/id_rsa.pub | ssh [remote_user]@[remote_server] "cat - >>.ssh/authorized_keys"
注:無密碼ssh登錄的基本原理是,在本地的root用戶下,用ssh-keygen命令生成一對密鑰,然后將其中的公鑰,追加到遠程服務器的authorized_keys文件中即可。密鑰對只對本地的生成用戶有效,其他用戶需要重新生成并添加。
3、掛載遠程 ssh 文件系統
#sshfs?gintama@172.31.30.57:/data/jdsdk/runtime/?/data/app_data/sdk/redis/
sshfs 用戶名@遠程主機IP:遠程主機路徑 本地掛載點
sshfs [user@]host:[dir] mountpoint [options]
前面和ssh命令一樣,mountpoint是掛載點options重點關注下:
-C 壓縮,或者-o compression=yes
-o reconnect 自動重連
-o transform_symlinks 表示轉換絕對鏈接符號為相對鏈接符號
-o follow_symlinks 沿用服務器上的鏈接符號
-o cache=yes -o allow_other 這個參數最重要,必須寫,否則任何文件都是Permission Deny
4、查看掛載情況,卸載掛載點 #mount 查看掛載情況
#umount mount_point 或 #fusermount -u mount_point 卸載掛載點
5、開機自動掛載 #sudo?sed?-i?'$a?sshfs#gintama@172.31.30.57:/data/jdsdk/runtime/?/data/app_data/sdk/redis/?fuse?defaults,auto,allow_other?0?0'?/etc/fstab #sudo?sed?-i?'$a\sshfs#gintama@172.31.29.97:/data/jdsdk/runtime/?/data/app_data/sdk/game/?fuse?defaults,auto,allow_other?0?0'?/etc/fstab?
6、fuse: failed to exec fusermount: Permission denied錯誤解決 提示錯誤: fuse: failed to exec fusermount: Permission denied fuse failed. Common problems: - fuse kernel module not installed (modprobe fuse) - invalid options -- see usage message
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀
總結
以上是生活随笔為你收集整理的【Linux sshfs】sshfs将远程目录挂载到本地目录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux常用网络命令总结
- 下一篇: sql like 多条件