リモートディレクトリをsshfsマウントしようとしましたが、マウントされたファイルに書き込めませんでした。デバッグするアイデアや方法が不足しています。リモートサーバーで確認する必要がありますか?
私はXubuntu 14.04を使用しています。 14.04 Ubuntuのリモートディレクトリをインストールしました。
local $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
/etc/fuse.confを変更しました。
local $ sudo cat /etc/fuse.conf
# /etc/fuse.conf - Configuration file for Filesystem in Userspace (FUSE)
# Set the maximum number of FUSE mounts allowed to non-root users.
# The default is 1000.
#mount_max = 1000
# Allow non-root users to specify the allow_other or allow_root mount options.
user_allow_other
私のユーザーはヒューズグループに属しています。
local $ sudo grep fuse /etc/group
fuse:x:105:MY_LOACL_USERNAME
次のコマンドを使用してリモートディレクトリをマウントしました(sudo、default_permissions、allow_otherの組み合わせを有効または無効にしようとしました)。
local $sudo sshfs -o allow_other,default_permissions -o IdentityFile=/path/to/ssh_key REMOTE_USERNAME@REMOTE_HOST:/remote/dir/path/ /mnt/LOCAL_DIR_NAME/
REMOTE_USERNAME
(リモートサーバー上の)ディレクトリ/ファイルへの書き込み権限が必要です。
sudo、default_permissionsなしで上記のコマンドを試しましたが、すべての場合で次のような結果が得られました。
local $ ls -al /mnt/LOCAL_DIR_NAME/a_file
-rw-rw-r-- 1 699 699 1513 Aug 12 16:08 /mnt/LOCAL_DIR_NAME/a_file
local $ test -w /mnt/LOCAL_DIR_NAME/a_file && echo "Writable" || echo "Not Writable"
Not Writable
説明0
ユーザー3188445のコメントに返信してください。
$ whoami
LOCAL_USER
$ cd
$ mkdir test_mnt
$ sshfs -o allow_other,default_permissions -o IdentityFile=/path/to/ssh_key REMOTE_USERNAME@REMOTE_HOST:/remote/dir/path/ test_mnt/
$ ls test_mnt/
I see the contents of the dir correctly
$ ls -al test_mnt/
total 216
drwxr-xr-x 1 699 699 4096 Aug 12 16:42 .
drwxr----- 58 LOCAL_USER LOCAL_USER 4096 Aug 17 15:46 ..
-rw-r--r-- 1 699 699 2557 Jul 30 16:48 sample_file
drwxr-xr-x 1 699 699 4096 Aug 11 17:25 sample_dir
$ touch test_mnt/new_file
touch: cannot touch ‘test_mnt/new_file’: Permission denied
# extra info: SSH to the remote host and check file permissions
$ ssh REMOTE_USERNAME@REMOTE_HOST
# on remote host
$ ls -al /remote/dir/path/
lrwxrwxrwx 1 root root 18 Jul 30 13:48 /remote/dir/path/ -> /srv/path/path/path/
$ cd /remote/dir/path/
$ ls -al
total 216
drwxr-xr-x 26 REMOTE_USERNAME REMOTE_USERNAME 4096 Aug 12 13:42 .
drwxr-xr-x 4 root root 4096 Jul 30 14:37 ..
-rw-r--r-- 1 REMOTE_USERNAME REMOTE_USERNAME 2557 Jul 30 13:48 sample_file
drwxr-xr-x 2 REMOTE_USERNAME REMOTE_USERNAME 4096 Aug 11 14:25 sample_dir
ベストアンサー1
この質問に回答しましたLinuxメーリングリスト;完全さのためにここに翻訳された答えを投稿します。
解決策
default_permissions
解決策は、インストール時に両方のオプションを使用しないことですallow_other
(初期実験ではこの方法を試していません)。
説明する
問題は簡単なようです。 Fusermountでオプションを使用すると、default_permissions
ヒューズマウントに対するヒューズの権限は次のように制御されます。コアによってではなくヒューズ。
これは、REMOTE_USERのuid / gidがLOCAL_USER(sshfs.c IDMAP_NONE)にマップされていないことを意味します。マッピングなしで単純なnfs fsと同じように機能します。
したがって、uid / gid番号が一致しない場合は、アクセスを拒否するのが妥当です。
このオプションがある場合、allow_other
ディレクトリはローカルユーザーuid 699(存在する場合)のみを書き込むことができます。
Fuse Guysから:
'default_permissions'
By default FUSE doesn't check file access permissions, the
filesystem is free to implement its access policy or leave it to
the underlying file access mechanism (e.g. in case of network
filesystems). This option enables permission checking, restricting
access based on file mode. It is usually useful together with the
'allow_other' mount option.
'allow_other'
This option overrides the security measure restricting file access
to the user mounting the filesystem. This option is by default only
allowed to root, but this restriction can be removed with a
(userspace) configuration option.