OSXFUSEとSSHFSでリモート資源を透過的にSFTP接続する
OSXをより便利に使おうと、時間があればあれこれツールを試しているのが、最近気に食わないのが SFTP ツールとして使っている Filezilla です。Retila 対応していないので HiDPI で表示させることができません。単純拡大表示になってしまい文字がにじむのがどうにも気に食わない。
HiDPI 対応させる裏技として「Info.plist に記述を追加してアプリを再配置してから低解像度で開くをOFFにする方法」がありますが、やってみてもRetina対応されないアプリの類で、非常に気に食わない。※ちなみにHiDPI対応させるにはInfo.plistに下記記述を追加する。
<key>NSHighResolutionCapable</key> <true/>
個別に HiDPI 対応させるべくソースを貪ってやろうと思うも、FileZilla は内部的に wxWidgets を使っていて、HiDPI 非対応の古い 2.8.x バージョンを前提として書かれていたので対応できそうにありませんでした。有料の Transmit を購入する前に、他の方法はないものかと探したところ、FUSE for OS X と SSHFS を使ってリモートサーバを mount して Finder 上に透過的に表示させる方法が、まぁ使える感じだったので備忘録として残しておきます。
結論を先に書いておきます。100%満足いく感じではありません。
- Finder に透過表示させると思った以上に非常に使い勝手が良い。
 - レスポンスが少々悪い。Filezilla など SFTP ツールを使ったほうが速度的な快適度は上。
 - スリープモードから復帰した時など一旦 PC のネットワークが切断されると当然リモート接続も切断され mount は解除される。
 - 編集中に mount が解除されるとファイルの変更内容が失われる。
 
OSXFUSEとSSHFSでリモート資源を透過的にSFTP接続する手順
1. OSXFUSE をインストール
FUSE for OS X(File system in user space implementation for OS X)のの最新版を配布サイトからダウンロードします。
ダウンロードした osxfuse-2.6.1.dmg をダブルクリックしてインストールします。インストール時のパッケージ選択の際に「Mac FUSE Compatibility Layer」をチェックします。
2. sshfs をインストール
sshfs (he SSH File System)最新版を配布サイトからダウンロードします。sshfs-gui という GUI ベースのツールも存在しますが、OSX 10.9 Mavericks では動作しませんでした。
ダウンロードした SSHFS-2.4.1.pkg をダブルクリックしてインストールします。下記のようなエラーが表示されてインストールができない場合には、「セキュリティとプライバシー 」から「すべてのアプリケーションを許可」に変更してから再度インストールを行って下さい。
正常にインストールできたかをターミナルから下記コマンドを実行して確認します。
TSUNODA-no-MacBook-Pro:mount drk$ sshfs --version SSHFS version 2.4 (OSXFUSE SSHFS 2.4.1) OSXFUSE library version: FUSE 2.7.3 / OSXFUSE 2.6.1 no mount point
3. sshfs でリモートサーバをマウント
リモートの資源をデスクトップ配下にマウントします。下記の環境と仮定します。
リモートサーバ名:user.server.com
リモートサーバアカウント:user
リモートユーザパスワード:password
リモートサーバ資源:/
ターミナルを開いて、下記のコマンドを実行します。マウントディレクトリがない場合には mkdir で作成します。
cd ~ mkdir ~/Desktop/user.server.com
続いてリモートサーバ資源の / をマウントします。サーバのパスワードを聞かれるので password を入力します。
sshfs user@user.server.com:/ ~/Desktop/user.server.com user@user.server.com's password: password
正常にマウントされると、デスクトップ上のアイコンが変化し、Finder から透過的にサーバ上のファイルを閲覧・編集できるようになります。
接続コマンドを入力したターミナルを CTRL + C でプロセスを終了させるとリモートサーバとの接続が切断され、マウントが解除されます。
TSUNODA-no-MacBook-Pro:mount drk$ sshfs -f apache@www.drk7.jp:/ ~/Desktop/user.server.com/ apache@www.drk7.jp's password: ^CKilled by signal 2. remote host has disconnected TSUNODA-no-MacBook-Pro:mount drk$
ちなみに、今回インストールした sshfs のオプションは下記の通り。sshfs -h でいつでも見られます。
usage: sshfs [user@]host:[dir] mountpoint [options]
general options:
    -o opt,[opt...]        mount options
    -h   --help            print help
    -V   --version         print version
SSHFS options:
    -p PORT                equivalent to '-o port=PORT'
    -C                     equivalent to '-o compression=yes'
    -F ssh_configfile      specifies alternative ssh configuration file
    -1                     equivalent to '-o ssh_protocol=1'
    -o reconnect           reconnect to server
    -o delay_connect       delay connection to server
    -o sshfs_sync          synchronous writes
    -o no_readahead        synchronous reads (no speculative readahead)
    -o sshfs_debug         print some debugging information
    -o cache=BOOL          enable caching {yes,no} (default: yes)
    -o cache_timeout=N     sets timeout for caches in seconds (default: 20)
    -o cache_X_timeout=N   sets timeout for {stat,dir,link} cache
    -o workaround=LIST     colon separated list of workarounds
             none             no workarounds enabled
             all              all workarounds enabled
             [no]rename       fix renaming to existing file (default: off)
             [no]nodelaysrv   set nodelay tcp flag in sshd (default: off)
             [no]truncate     fix truncate for old servers (default: off)
             [no]buflimit     fix buffer fillup bug in server (default: on)
    -o idmap=TYPE          user/group ID mapping, possible types are:
             none             no translation of the ID space
             user             only translate UID/GID of connecting user (default)
             file             translate UIDs/GIDs contained in uidfile/gidfile
    -o uidfile=FILE        file containing username:remote_uid mappings
    -o gidfile=FILE        file containing groupname:remote_gid mappings
    -o nomap=TYPE          with idmap=file, how to handle missing mappings
             ignore           don't do any re-mapping
             error            return an error (default)
    -o ssh_command=CMD     execute CMD instead of 'ssh'
    -o ssh_protocol=N      ssh protocol to use (default: 2)
    -o sftp_server=SERV    path to sftp server or subsystem (default: sftp)
    -o directport=PORT     directly connect to PORT bypassing ssh
    -o slave               communicate over stdin and stdout bypassing network
    -o transform_symlinks  transform absolute symlinks to relative
    -o follow_symlinks     follow symlinks on the server
    -o no_check_root       don't check for existence of 'dir' on server
    -o password_stdin      read password from stdin (only for pam_mount!)
    -o SSHOPT=VAL          ssh options (see man ssh_config)
FUSE options:
    -d   -o debug          enable debug output (implies -f)
    -f                     foreground operation
    -s                     disable multi-threaded operation





コメントやシェアをお願いします!