皆さん。最近 autofs に出会い、日々の生活を楽にしようとしています。何年も sshfs の助けを借りてファイル共有に使用しているリモート サーバーがあります。そこで、autofs の助けを借りて sshfs を自動化する方法についてのチュートリアルをいくつか見つけました。これが私の設定です。
オートマスター:
/home/user/autofs/ /etc/autofs/auto.sshfs uid=1000,gid=1000,--timeout=300,--ghost
自動.sshfs:
cux -fstype=fuse,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa :sshfs\#[email protected]\:/path/to/files
リモート サーバーは ssh キーのみを受け入れるため、マウント ポイントにアクセスしようとしているユーザーには、キーがインポートされた ssh エージェントが実行されています。
しかし、マウント ポイントにアクセスしようとすると、次のメッセージが表示されます。
Dec 31 18:56:37 ice automount[25565]: mount(generic): calling mount -t fuse -o uid=1000,gid=1000,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa sshfs#[email protected]:/path/to/files /home/user/autofs/cux
Dec 31 18:56:37 ice automount[25565]: spawn_mount: mtab link detected, passing -n to mount
Dec 31 18:56:37 ice automount[25565]: >> read: Connection reset by peer
Dec 31 18:56:37 ice automount[25565]: mount(generic): failed to mount sshfs#[email protected]:/path/to/files (type fuse) on /home/user/autofs/cux
Dec 31 18:56:37 ice automount[25565]: dev_ioctl_send_fail: token = 67
Dec 31 18:56:37 ice automount[25565]: failed to mount /home/user/autofs/cux
しかし、sshfs でマウントすると (自分のユーザーから):
sshfs -p 222 server.com:/path/to/files /home/user/remote/cux -o reconnect
成功します。autofs がルートから実行するのとまったく同じコマンドを使用した場合でも、autofs は次のように動作します。
mount -t fuse -o uid=1000,gid=1000,port=222,rw,nodev,noatime,allow_other,IdentityFile=/home/user/.ssh/id_rsa sshfs#[email protected]:/path/to/files /home/user/autofs/cux
これも成功します。しかし、問題は ssh キーのようです。ユーザー キーをインポートせずに (su -) ルートからマウント コマンドを実行すると、パスワードの入力を求められます。この問題を回避して、マウント ポイントにアクセスしているユーザーの ssh キーを autofs が使用するようにする方法はありますか?