最近架設了一台外網伺服器,專門用於bt、電驢的下載。原先使用samba服務進行檔案訪問,後來發現,Linux下訪問samba服務太慢,百兆鏈路,只有幾百KB/s的速度。經推薦,開始使用sshfs,速度很快,速度經常能上10MB/s。
安裝 emerge sshfs-fuse
使用 mkdir mountpoint
sshfs [remote_user]@[remote_server]:[remote_directory] [mountpoint] -o allow_other
也可以自動掛載,主要分兩步
1、設定對遠程伺服器的無密碼登入
如圖所示,無密碼ssh登入的基本原理是,在本地的root使用者下,用ssh-keygen命令產生一對密鑰,然後將其中的公開金鑰,追加到遠程伺服器的authorized_keys檔案中即可。金鑰組只對本地的產生使用者有效,其他使用者需要重建並添加。命令如下: ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh [remote_user]@[remote_server] "cat - >>.ssh/authorized_keys"
2、修改fstab
如下添加一行: sshfs#[remote_user]@[remote_server]:[remote_directory] [mountpoint] [mountpoint] fuse allow_other 0 0
參考文檔:
《Linux實現無密碼登入》
番外篇:
windows的sshfs
windows的sshfs是以dokan library+dokan sshfs的形式實現的。
訪問這裡: Dokan:http://dolan-dev.net/en/download/
依次下載安裝: Microsoft Visual C++ 2005 SP1 Redistributable Package dokan-0.5.2 dokan-sshfs-0.2.0.1226 dokan-sshfs-for-dokan-050.zip
即可