root権限のあるLinuxマシンを用意する。ないときはVirtualBox等のVM上にLinuxを構築しよう。ここではUbuntuを前提として書く。
sshfsのインストールと設定
sshfsをインストールする。
# apt-get install sshfs
/etc/fuse.conf を書き換える。user_allow_otherのコメントを外す。これにより、マウントしたユーザ以外もフォルダを見ることができるようになる*1。
user_allow_other
マウントポイントを作成する。
# mkdir -p /mnt/remote/hoge.org
起動スクリプトを書く。ユーザ権限でマウント操作を実行するが、このとき allow_other オプションを指定するのがポイントである。
vim /etc/init.d/sshfs-hoge.org
#!/bin/sh ### BEGIN INIT INFO # Provides: sshfs # Required-Start: $network $local_fs $remote_fs # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Mount hoge.org via sshfs ### END INIT INFO . /lib/lsb/init-functions case "$1" in start) log_daemon_msg "Mount hoge.org via sshfs" su ローカルのユーザID -c 'sshfs リモートのユーザID@ホスト名:. /mnt/remote/hoge.org -o idmap=user,allow_other,transform_symlinks' ;; stop) log_daemon_msg "Unmount hoge.org" umount /mnt/remote/hoge.org ;; esac exit 0
サービスを開始する。
# /etc/init.d/sshfs-hoge.org start
必要に応じて、起動時に開始するか設定する。
# sysv-rc-conf
公開鍵認証の設定
リモートサーバで鍵を生成する。パスフレーズは空にしておく。
$ ssh リモートのユーザID@ホスト名 Enter password: 〜 リモート$ ssh-keygen -b 1024 リモート$ logout
秘密鍵をローカルにコピーする。
$ scp リモートのユーザID@ホスト名:.ssh/id_dsa .ssh
sambaのインストールと設定
sambaをインストールする。
# apt-get install samba swat # smbpasswd ローカルのユーザID Enter password: 〜
あとはwindowsマシンからWeb経由で設定を行う。
http://LinuxマシンのIPアドレス:901/
参考までに、うちの設定の一部を掲載する。
[global] server string = load printers = No dns proxy = No invalid users = root create mask = 0644 [home] path = /home/hoge valid users = hoge read only = No [remote] path = /mnt/remote valid users = hoge read only = No