このオプションに注意してください:
<ブロック引用>-o SSHOPT=VAL ssh オプション (man ssh_config を参照)
man ssh_config を見ると IdentityFile という秘密鍵ファイルへのパスを設定するオプションがあります。 、これを行うことができます:
sshfs -oIdentityFile=/abs/path/to/id_rsa server: path/to/mnt/point
ID ファイルへのパスは絶対パスでなければなりません。
原則として、このように動作します (root として、または sudo を使用) ):sshfs -o default_permissions,nonempty,IdentityFile=/home/USER/.ssh/id_rsa [email protected]:PATH /mnt/mountpoint
USER を置き換えます authorized_keys にいるユーザーと サーバーのファイル、SERVER サーバー名 (または 192.168.0.11 のような IP)、SRVUSER サーバー上のユーザーと一緒に (例:root、推奨されませんが、可能で必要な場合もあります; /etc/ssh/sshd_config をセットアップします) サーバー上でこれを正しく実行します。つまり、ディレクティブ PermitRootLogin および PasswordAuthentication )。 /mnt/mountpoint も置き換えます
オプション -o nonempty このディレクトリが空でない場合、/mnt/mountpoint をマウントできます。ファイル .unmounted を保持しているので、これを使用する必要があります このディレクトリでマウントされているかどうかを確認するため、 test -e /mnt/mountpoint/.unmounted の場合 成功を返します (つまり、ファイル .unmounted が /mnt/mountpoint に存在する)、マウントされていません。
実際の例:
- サーバー名「ホームサーバー」
- サーバーに /home ディレクトリをマウントする
- ローカル システムのマウントポイントは /mnt/homeserver です
- ユーザー「steve」は秘密鍵を持っています
ssh [email protected] ユーザー steve が働いたので。
sshfs -o default_permissions,nonempty,IdentityFile=/home/steve/.ssh/id_rsa [email protected]:/home /mnt/homeserver (ルートとして)
うまくいきませんでした 、次のエラー メッセージが表示されました:read: Connection reset by peer
解決策: -o debug を追加して、より詳細な出力を取得します .
# sshfs -o default_permissions,nonempty,IdentityFile=/home/steve/.ssh/id_rsa,debug
[email protected]:/home /mnt/homeserver
FUSE library version: 2.9.8
nullpath_ok: 0
nopath: 0
utime_omit_ok: 0
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStT0123
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:2
ECDSA host key for homeserver has changed and you have requested strict checking.
Host key verification failed.
read: Connection reset by peer
そして突然、修正がはるかに簡単になります。 sshd キーは前回のセッション以降に再作成されたが /root/.ssh/known_hosts であるため ローカル システムにはまだ古いキーが残っているため、機能しません。私の場合、解決策は homeserver で始まる行を削除するだけでした。 /root/.ssh/known_hosts から エディターを使用する (nano など) )。 sshfs でのマウントが機能するようになりました。最初のマウント時に、新しいキーを確認する必要があります:
# mount /mnt/homeserver
The authenticity of host 'homeserver (192.168.0.11)' can't be established.
ECDSA key fingerprint is SHA256:aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsS/1234.
Are you sure you want to continue connecting (yes/no)? yes
ところで、これは /etc/fstab の行です :
[email protected]:/home /mnt/homeserver fuse.sshfs noauto,nonempty,default_permissions,IdentityFile=/home/steve/.ssh/id_rsa 0 0
それ以外でもいいので -o debug を試してみてください 最初。間違いを見つけるのに非常に役立ちます。