ubuntu - Using pscp and getting permission denied

08
2013-08
  • Espen

    I'm using pscp to transfer files to a virtual ubuntu server using this command:

    pscp test.php user@server:/var/www/test.php
    

    and I get the error permission denied. If I try to transfer to the folder /home/user/ I have no problems.

    I guess this has to do with that the user I'm using doesn't have access to the folder /var/www/. When I use SSH I have to use sudo to get access to the /var/www/ path - and I do.

    Is it possible to specify that pscp should "sudo" transfers to the server so I can get access to the /var/www/ path and actually be able to transfer files to this folder?

  • Answers
  • ngen

    You're most likely correct that you don't have access to /var/www/. What you can do is chmod /var/www/ to allow guest to write and change it back to original state once complete (I would advice against this). You can add the user to the group that owns /var/www/ and make sure the group is set for read/write/execute.


  • Related Question

    How do I get permissions to save in a folder that Windows 7 denies me from?
  • Questioner

    I'm getting this message - You don't have permissions to save in this folder - even though I am the only user on this machine, and administrator.

    How can I set permissions for myself to do everything, everywhere (including saving deleting etc)?

    Edit: Sorry, forgot to say which folder it was. It is a folder in Program Files, where I save my PHP files for local testing.

    Sorry if Im a bit daft with all this, but I've upgraded straight from XP to 7, and having never used vista, I'm used to being allowed to have full control.


  • Related Answers
  • 8088

    This is due to UAC (User Access/Account Control) On Windows Vista / 7, and trying to write to a protected folder.

    Typically Windows 7 has much lower UAC, but it is still there, especially with older programs that are trying to write to places.

    You need to not double click on a file to open, but right click on the program that it opens up in, and click "Run as Administrator", for example to launch command prompt.

    alt text

    When you save, you should be able to write to almost anywhere.

  • jtreser

    I would get out of the habit of manually creating files in the "Program Files" folder. The purpose of that location is to hold static application files. You can force the files there by changing permissions on the folder or accepting the UAC prompt when doing a manual copy but if your application expects to change data there you have to elevate privileges. See http://stackoverflow.com/questions/946420/allow-access-permission-to-write-in-program-files-of-windows-7 for a good discussion of this.

  • sonny

    To save file to a Program Folder in Windows 7, you will need to right click the folder whewre you want to save --> Properties, then go to the Security tab, highlight "Users" and then click "Edit..." Give it full control and apply, back out the windows and you should be able to save. When you are done, be sure to go back and uncheck the full control and write boxes.

  • Someguy

    Right click the folder, click properties, open security tab, edit the users (or your computer name) tick the modify(I tick all).

    It works, I also use php and save it to htdocs, it works without the need of running as admin, which wont do to folders

  • Josip Medved

    This appears when you do not have enough permissions to write to this folder without your administrative credentials (given to you by UAC).

    You can right-click on that folder and select Permissions. Then go to Security tab. Once you are there, you will see that Users have only read rights. Change that to Full access and Windows will not complain anymore.