incorrect permissions after copying over scp

I'm using cygwin in windows 7 to copy a directory to an ubuntu machine using this command.

scp -rp -P 54322 /cygdrive/c/xampp/htdocs/. user@10.136.10.1:/home/user/somefolder/

After copying all the files, they all have "no read, no write" permissions. Does anyone know why?

Alternatively if I copy /cygdrive/c/xampp/htdocs/ to /cygdrive/c/Users/user and then use scp to copy the files. The permissions are correct.

---------- 1 user user 1273 Apr 21 16:32 about.html
---------- 1 user user 1707 Apr 21 16:33 contact.html
d--------- 2 user user 4096 Apr 21 04:14 images
---------- 1 user user 2259 Apr 21 22:27 index.html
---------- 1 user user 1252 Apr 21 16:33 projects.html
---------- 1 user user 823 Apr 22 22:03 style.css
drwx------ 6 user user 4096 Apr 21 02:11 xampp
2

3 Answers

I've had some issues with rsync/ssh and cygwin, this is how I managed to solve:

  • Disable acl's as these cannot be properly mapped to Linux ACL's
  • Check mount options before changing:

$ mount

D:/ProgramsVista/ICW/etc/terminfo on /usr/share/terminfo type ntfs (binary,noacl)
D:/ProgramsVista/ICW/bin on /usr/bin type ntfs (binary,noacl)
D:/ProgramsVista/ICW/lib on /usr/lib type ntfs (binary,auto)
D:/ProgramsVista/ICW on / type ntfs (binary,noacl)
C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
E: on /cygdrive/e type iso9660 (binary,posix=0,user,noumount,auto)
  • Change setting for ACL's

cp /etc/fstab /etc/fstab.install

echo "none /cygdrive cygdrive binary,posix=0,user,noacl 0 0" >> /etc/fstab

  • To activate the new setting, logout and login again

logoutssh Adminstrator@hostname

  • Check the new setting for "noacl":

$ mount

D:/ProgramsVista/ICW/etc/terminfo on /usr/share/terminfo type ntfs (binary,noacl)
D:/ProgramsVista/ICW/bin on /usr/bin type ntfs (binary,noacl)
D:/ProgramsVista/ICW/lib on /usr/lib type ntfs (binary,auto)
D:/ProgramsVista/ICW on / type ntfs (binary,noacl)
C: on /cygdrive/c type ntfs (binary,noacl,posix=0,user,noumount,auto)
D: on /cygdrive/d type ntfs (binary,noacl,posix=0,user,noumount,auto)
E: on /cygdrive/e type iso9660 (binary,noacl,posix=0,user,noumount,auto)

(sorry can't seem to get the formatting right this morning.)

1

Since you are copying from an NTFS drive (with windows-like permissions) Cygwin is essentially "making up" a set of unix like permissions. As you copy the files to a real unix-based system, those permissions become relevant. Since you are using the -p option on scp, you are retaining the permissions that Cygwin "made up". The receiving system either doesn't have a user with that UID, or at the very least your user account is not the one with that UID, so you do not have permission to even see the permissions.

The easiest way to fix this is to take ownership of the files on the linux side.

chown $(whoami):$(whoami) ~/somefolder -R
chmod 750 -R ~/somefolder/

from the linux desktop, which will give you rwx permssions to the user, rx to the group, and no access to others. Or drop the -p from scp which should use your user account's UMASK to generate new permissions on the unix side

4

Use an additional flag. From man scp:

 -p Preserves modification times, access times, and modes from the original file.
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like