インストール方法
まずは、ローカルのPCに
・osxfuse
・sshfs
の二つをインストールします。
Macで、Homebrewが入って入れば以下でインストール可能です。
$brew cask install osxfuse
$brew install sshfs
マウントする
*マウント先のサーバーにはsshで接続できることが前提です。
次に以下のコマンドで、実際にマウントします。
$sshfs username@hostname:/var/www/destination /Users/yourname/path/to/mountpoint -p ポート番号 -o IdentityFile=~/.ssh/samplesecret.pem
・username=マウント先サーバーのユーザー名
・hostname=マウント先サーバーのホスト名
・/var/www/destination=マウント先サーバーのマウントしたいディレクトリ名
・/Users/yourname/path/to/mountpoint=ローカルPCでマウントしたいディレクトリ名
(ローカルの/Users/yourname/path/to/mountpointとリモートの/var/www/destinationがマウントされます。)
・IdentityFile=ssh接続する時の公開鍵
host名を設定しているとき
configファイルで,Hostを設定しているとき,
例えば「ssh samplehost」だけでssh接続できるときは
$ssh samplehost
以下だけでOK
$sshfs samplehost:/var/www/destination /Users/yourname/path/to/mountpoint
アンマウントしたい時
アンマウントしたい時は以下のコマンドです。
アンマウントしたいローカルのディレクトリの絶対パスを指定します。
diskutil umount /Users/yourname/path/to/mountpoint
もし、これで失敗した場合は、プロセス確認し、killします。
そして、umount -fでアンマウントしてください
$ pgrep -lf sshfs
2449 sshfs root@*********:/var/www/xxxx /Users/yourname/path/to/mountpoint
$ kill -9 2449
$ umount -f /Users/yourname/path/to/mountpoint