普段NFSでマウントする事が多いが、ここではルータ越えでも可能なsshfsを使用して必要時に自動的にマウントする方法を記述する。
 なお、クライアント側はLinux Mint、サーバ側はCentOSの構成で行い、マウント方法は扱いやすいダイレクトマップ方式で行う。
Contents
サーバ側
クライアントからsshで接続出来るようsshdを設定する。
 ※特にiptablesでポートが開けてあるか確認する。
クライアント側
sshfs,autofsのインストール
1 2  | sudo apt-get update sudo apt-get install sshfs autofs  | 
キーペアの作成
1  | ssh-keygen -t rsa  | 
※パスフレーズは省略する為以下の問いには空Enterを入力する
 Enter passphrase (empty for no passphrase):
 Enter same passphrase again:
作成した公開鍵をサーバに登録する
1  | ssh-copy-id -i ~/.ssh/id_rsa.pub サーバ名  | 
パスワードなしで正常にログインできるか確認する
1 2  | ssh サーバ名 exit  | 
fuseの設定
/etc/fuse.confのuser_allow_otherの#を外して有効にする。
1  | sudo vi /etc/fuse.conf  | 
1 2 3 4 5 6 7 8  | # /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE) # Set the maximum number of FUSE mounts allowed to non-root users. # The default is 1000. #mount_max = 1000 # Allow non-root users to specify the allow_other or allow_root mount options. user_allow_other  | 
ユーザにfuseグループを追加し、再起動する
1 2  | sudo usermod -a -G fuse ユーザ名 sudo reboot  | 
autofsの設定
ダイレクトマップの設定を行う。
1  | sudo vi /etc/auto.master  | 
22 23 24 25 26 27 28  | # Note that if there are entries for /net or /misc (as # above) in the included master map any keys that are the # same will not be seen as the first read key seen takes # precedence. # +auto.master /-      /etc/auto.direct  | 
1  | sudo vi /etc/auto.direct  | 
1  | マウントポイント -fstype-fuse,uid=クライアント側のuid,gid=クライアント側のgid,allow_other,IdentityFile=作成した秘密鍵(id_rsa)のパス :sshfs\#ユーザ名@サーバ名\:サーバ側のパス  | 
上記でサーバ側のパスがマウントポイントにマウントされているはずなので、dfでマウント前の状態を確認しておき、lsでマウントポイントを表示した後に再度dfを実行し正常にマウントされたか確認する。