sshfsでリモートホストのファイルシステムをマウント

  • 環境
    • CentOS 5

fuse,fuse-sshfsパッケージインストール

# yum install -y fuse fuse-sshfs
Installed:
  fuse.i386 0:2.7.4-8.el5                                                fuse-sshfs.i386 0:2.2-5.el5

Complete!

マウントする

  • sshログインできるホストであればマウントできるはず。
$ mkdir remote
$ sshfs user@remotehost: remote/
user@remotehost's password:
fuse: failed to exec fusermount: Permission denied
  • エラー。fusermountを実行できないそうです。

fusermountのパーミッションを設定

  • 探す
$ rpm -ql fuse
/bin/fusermount
  • パーミッションの状態を確認
$ ls -l /bin/fusermount
-rwsr-x--- 1 root fuse 21076  9月  4  2009 /bin/fusermount
  • パーミッション変更
$ sudo chmod o+rx /bin/fusermount
  • パーミッションが変更されたことを確認
$ ls -l /bin/fusermount
-rwsr-xr-x 1 root fuse 21076  9月  4  2009 /bin/fusermount

再度マウントしてみる

$ sshfs user@remotehost: remote/
  • マウント成功

アンマウント

$ fusermount -u remote

オプション指定のバリエーション

  • sshポートを2000番にしている場合
$ sshfs user@remotehost: -p 2000 remote/
  • identity file(秘密鍵ファイル)をid_rsa_hogehogeにしている場合
$ sshfs user@remotehost: -o IdentityFile=~/.ssh/id_rsa.dondari.com remote/

facebook slideshare rubygems github qiita