sshfs-win icon indicating copy to clipboard operation
sshfs-win copied to clipboard

Access denied when trying to read or write files

Open eric-wieser opened this issue 7 years ago • 13 comments

Presumably this is related to the sshfs --allow-other argument. How do I add this argument through net use or map network drive?

eric-wieser avatar Feb 05 '17 17:02 eric-wieser

I have a similar problem. I just have read-only access when using sshfs-win. Using Dokan, I can also write to files (but it crashes regularly, so I'm looking for an alternative).

The only weird thing about my server is that the home directory is on AFS, but that shouldn't be a concern for ssh (it is a relatively transparent filesystem). Also, I cannot write to /tmp, which is on the server's hard disk, and should work in any case.

I also tried using the syntax \\sshfs\winuser=remoteuser@host\path, but it didn't have any effect. All files on the mounted drive are owned by SYSTEM, and read only.

jdmansour avatar Feb 23 '17 14:02 jdmansour

@eric-wieser @jdmansour Apologies for not looking at any of these issues recently. I am totally focused on making WinFsp as robust and capable as possible and have not had time to look into sshfs-win.

Sshfs-win.c is the small driver program that starts sshfs with (hopefully) the correct parameters. Sshfs-win.c attempts to start sshfs with a -ouid=UID,gid=GID option that matches the USER in the \\sshfs\USER@HOST syntax (or the LOCUSER in the \\sshfs\LOCUSER=USER@HOST syntax).

To fetch the UID, GID it does a (Cygwin) getpwnam. The minimal Cygwin environment included in sshfs-win, should have the same usernames as Windows. Note however that if a domain username is encountered, Cygwin translates \ to + (I believe). So for example DOMAIN\USER becomes DOMAIN+USER.

I also tried using the syntax \\sshfs\winuser=remoteuser@host\path, but it didn't have any effect. All files on the mounted drive are owned by SYSTEM, and read only.

This means that for some reason getpwnam failed. When this happens, sshfs is started with the -ouid=-1,gid=-1 switch which makes all files owned by the account that starts sshfs (in this case SYSTEM).

billziss-gh avatar Feb 25 '17 18:02 billziss-gh

Is there any easy way to evaluate getpwnam in the minimal cygwin environment that is included?

eric-wieser avatar May 11 '17 22:05 eric-wieser

If you have Cygwin installed, you just need to issue id from the bash prompt. This will tell you what uid and gid, Cygwin thinks you have.

If you do not have Cygwin it is harder as SSHFS-Win does not include Cygwin bash.exe in its distribution.

billziss-gh avatar May 11 '17 22:05 billziss-gh

If you do not have Cygwin it is harder as SSHFS-Win does not include Cygwin bash.exe in its distribution.

Yep, that was my concern. Either way, after updating both winfsp and sshfs-win, this seems to now be working just fine for me with the appropriate local user.

eric-wieser avatar May 11 '17 23:05 eric-wieser

Bash.exe may be a bit big to distribute, but perhaps I could just distribute /usr/bin/id. Although it then becomes a question of complying with licenses, which is not always a fun job...

billziss-gh avatar May 11 '17 23:05 billziss-gh

Adding sshfs-win --show-id localuser would probably be enough to debug this issue

eric-wieser avatar May 11 '17 23:05 eric-wieser

Hello, I know this is a bit old but after installing WinFSP and SSHFS-WIN I am able to mount to my ubuntu server through SSH and although I can create new files I can not edit any existing files (access is denied). I am logged in on a domain joined workstation and the users I am using is a separate user (which is an a sudoer on the ubuntu server). Is there any way to fix this?

oden08 avatar Jul 31 '17 20:07 oden08

@oden08 apologies for the late response.

Have you tried the following syntax:

\\sshfs\DOMAIN+WINUSER=USER@HOST\PATH

billziss-gh avatar Sep 01 '17 22:09 billziss-gh

I have similar problem, after a little bit debugging, I can see that, parameters passed as:

-ouid=4096 ,gid=4096

which is matching on my cygwin install, output of id command

but when I looked at the files on cygwin, i see user, and group as -1

bluesign avatar Nov 23 '17 13:11 bluesign

I have this same problem with permission. I can set up a connection via 'map network drive', but only with READ permission. Can you help me use this program by CMD and create a connection?

I have the following data:

  • Windows user name: Michal
  • Windows mountpoint: I don't know, please help me there (choose random).
  • Windows UID: uid=197608(Michal)
  • Windows GID: gid=197121(None)
  • Remote IP: 192.168.2.10
  • Remote directory: /home/pi
  • Remote user name: pi
  • Remote password: michal3

Activities I've done:

  1. Install latest winfsp with all optionals packages
  2. Install latest sshfs-win 64-bits
  3. Install latest cygwin 64-bits with defaults packages
  4. Run Cygwin-Terminal and type command: id username
  5. Copy UID and GID
  6. Look for SSHFS-Win\bin\sshfs.exe program in your disk
  7. Open this program through CMD

I get the following message for each connection attempt: read: Connection reset by peer

michal037 avatar Jun 17 '18 16:06 michal037

Same issue here, but I don't use Cygwin.

When I hit "Create Directory" once it creates four directories (that's another issue) with permission rwx------ 2. I can't access them or delete them.

GuillaumeDesforges avatar Feb 19 '19 10:02 GuillaumeDesforges

I have the same "read only" problem of having access to the mounted FS, but not being able to write.

Has anybody found a work-around for this? I've been searching high and low for a solution, but haven't found one.

I don't have any odd characters in my id (as mentioned in #168), so I don't think that's the issue.

I've tried setting uid and gid to those values on the target Linux system, but that didn't work. I've set the umask to 000 (though that's the default already), but that didn't work.

I would like to be able to use a Windows based editor on Linux files using ssh-win. If I can't get this working, I'll have to use vim over Putty/ssh. Vim is ok for quick edits, but I'd rather not for "hardcore" development.

cfreehill avatar Apr 01 '22 15:04 cfreehill

Using sshfs-win.exe I also get only readonly access. I added -o uid=-1 -o gid=-1 to sshfs-win: "c:\Program Files\SSHFS-Win\bin\sshfs-win.exe" cmd xxxx@yyyy: S: -o uid=-1 -o gid=-1 -o umask=002 -o create_file_umask=113 -o create_dir_umask=002 -o follow_symlinks or "c:\Program Files\SSHFS-Win\bin\sshfs-win.exe" cmd xxxx@yyyy:/ S: -o uid=-1 -o gid=-1 -o umask=002 -o create_file_umask=113 -o create_dir_umask=002 -o transform_symlinks to get also write access.

rfried1 avatar May 09 '23 13:05 rfried1