0

I don't understand how this solution worked for everybody who wanted to mount a volume as a read-only directory using sshfs. Everyone suggest using the 'ro' option. I did that, but the files in the mounted volume are still writeable. Why it doesn't work for me?

sshfs -p 2221 -o ro,idmap=user,reconnect,dev,IdentityFile=/home/user/.ssh/volume_key,Ciphers=arcfour  myuser@XXXXXX://base-dir/  mountpoint/

The permission of the folder on the remote volume is 777, the permissions of the local folder are 755, the user on my local machine and the remote machine are the same and the user:group on the local folder is myuser:myuser, after mounting it becomes 1027:users. So mounting the folder changes both the permissions and the owners of the folder, no matter if I use 'ro' or not.

  • 1
    Are you getting any other errors when you try to run that line? I tested it and it worked for me, but I removed the idmap=user part. – Terrance Sep 23 '18 at 4:39
  • It does not work for me. The permission of the folder on the volume is 777, the permissions of the local folder are 755, I use 'ro' option and remove the idmap=user, the user on my local machine and the remote machine are the same. Can you please tell me if yours is different from what I have here. – Alex Sep 23 '18 at 13:11
  • 1
    For me, I already put my ssh key on the server I connect to via ssh-copy-id. I made my /cifs_mount folder have 777 on it as I use that folder for testing. Then when I connected to my server this was all I did sshfs -o ro terrance@10.0.0.220:/media/storage /cifs_mount/. Then tested it by $ touch /cifs_mount/testfile.txt touch: cannot touch '/cifs_mount/testfile.txt': Read-only file system – Terrance Sep 23 '18 at 13:55
  • ah, gotcha! I cannot create a new file in the mounted directory. I was confused because the permission is still 777 but it does not allow me to write anything. How does it do that while the permissions are that wide!! Interesting! – Alex Sep 23 '18 at 17:31
  • 1
    One other thing to pay attention to. When you run the mount command by itself, it will show you all the mounts on your system and how they are running. At the end of each line it will show something like: (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000) and the particular line of the mount for the sshfs with the ro looks like (ro,nosuid,nodev,relatime,user_id=1000,group_id=1000). It is always at the beginning of that part if it is in Read Write (rw) or Read Only (ro). – Terrance Sep 24 '18 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.