Linux – SFTP’s “get” needs write permission

linuxpermissionssftp

I'm connecting to a server using sftp through console. I'm trying to download a folder which has some files without write permission for anyone. When I use get, those files throw an error that says I need write permissions, but the rest download fine.

It seems to be a problem with the console program, I tried WinSCP and it works fine, but I'd like to know if it's possible to do it from a terminal without changing permissions.

The local system runs Windows 7 with Cygwin, the remote one Ubuntu 12.04.

Example:

Couldn't open local file "website/sites/default/default.settings.php" for writing: Permission denied
Download of file /var/www/website/sites/default/default.settings.php to website/sites/default/default.settings.php failed

EDIT:

Permissions on remote server:

website/             755
sites/               775
default/             555
default.setting.php  664

The local directory in which I start sftp has 755 permissions. After the get, files and directories seem to retain the same permissions they had on the remote server, so since default has no write permissions, nothing can be downloaded into it.

How can I get files without retaining the original permissions?

Best Answer

Running the console program as administrator solved this problem, for me, on Windows 10. I use git bash. As @Flup said, you must have write permission in the directory where you start the sftp client.

Related Question