scp to location on remote that requires sudo gives Permission denied error

user61766

I have a ubuntu server to which I login as admin which can do sudo . On this server I have created dir /opt/myapp. I had to do sudo mkdir otherwise it would not work. Now from my desktop I want to do:

scp myfile [email protected]:/opt/myapp

but I get Permission denied. But if I

scp myfile [email protected]:

works fine and myfile is in /home/admin directory.

How to solve this problem?

Art Hill

First... maybe this is not a good idea. It may be that the permissions are set this way to stop people from doing exactly what you are trying to do for some good reason. That said, you are the captain of your destiny.

Find out who can write to that dir. Do:

ls -ld /opt/myapp

and you will get something like:

drwxr-xr-x 6 myapp_user myapp_group 55 Sep 10  2016 /opt/myapp

Potential Option 1: switch to the user account that is built for that app. eg:

scp myfile [email protected]:/opt/myapp

But you likely do not have the password for that user. Potentially, you can solve that by authenticating with a key. https://www.techrepublic.com/article/how-to-use-secure-copy-with-ssh-key-authentication/

Potential Option 2: Change the permissions of the dir '/opt/myapp' to 774 (or 770)

chmod 774 /opt/myapp

Then make the admin user a member of the group that now has write permissions. https://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/ This one is not great as you may run into trouble with being blocked from over-writing files (depending on what is going on).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

sudo error permission denied

From Dev

key works for logging in via ssh, but scp gives permission denied

From Dev

Can't scp file from local to remote host - Permission denied

From Dev

Sudo mkdir fails due to permission denied error

From Dev

Chrooted sftp gives "Permission denied" error

From Dev

gVim gives [Permission Denied] when using --remote-silent

From Dev

scp to remote server with sudo

From Dev

terminator: permission denied for sudo

From Dev

Server gives me a permission error when trying to scp, but not when ssh

From Dev

Server gives me a permission error when trying to scp, but not when ssh

From Dev

Google cloud scp permission denied

From Dev

(Scp - Permission Denied (Public Key)

From Dev

Google cloud scp permission denied

From Dev

Error: EACCES, permission denied even after using sudo?

From Dev

fail to ssh remote host with error message "Permission denied (publickey)"

From Dev

“sudo ecryptfs-recover-private” gives “find: ‘/run/user/1000/gvfs’: Permission denied” - Files Lost?

From Dev

Permission denied for all sudo comands

From Dev

Permission denied for all sudo comands

From Dev

Permission denied on Chromebook even with sudo

From Dev

sudo as user permission denied on command

From Dev

CDIR= $(pwd) gives "Permission denied"

From Dev

apk tool gives permission denied

From Dev

sudo permission denied but su grants permission

From Dev

Transfer files using scp: permission denied

From Dev

Transfer files using scp: permission denied

From Dev

scp permission denied after 'hardening' with bastille

From Dev

'Permission denied' problem with 'scp' while building blockchain

From Dev

Remote: Permission to repo denied at github

From Dev

Permission Denied Error when using scp to copy a file to Amazon EC2 instance from Mac OS

Related Related

  1. 1

    sudo error permission denied

  2. 2

    key works for logging in via ssh, but scp gives permission denied

  3. 3

    Can't scp file from local to remote host - Permission denied

  4. 4

    Sudo mkdir fails due to permission denied error

  5. 5

    Chrooted sftp gives "Permission denied" error

  6. 6

    gVim gives [Permission Denied] when using --remote-silent

  7. 7

    scp to remote server with sudo

  8. 8

    terminator: permission denied for sudo

  9. 9

    Server gives me a permission error when trying to scp, but not when ssh

  10. 10

    Server gives me a permission error when trying to scp, but not when ssh

  11. 11

    Google cloud scp permission denied

  12. 12

    (Scp - Permission Denied (Public Key)

  13. 13

    Google cloud scp permission denied

  14. 14

    Error: EACCES, permission denied even after using sudo?

  15. 15

    fail to ssh remote host with error message "Permission denied (publickey)"

  16. 16

    “sudo ecryptfs-recover-private” gives “find: ‘/run/user/1000/gvfs’: Permission denied” - Files Lost?

  17. 17

    Permission denied for all sudo comands

  18. 18

    Permission denied for all sudo comands

  19. 19

    Permission denied on Chromebook even with sudo

  20. 20

    sudo as user permission denied on command

  21. 21

    CDIR= $(pwd) gives "Permission denied"

  22. 22

    apk tool gives permission denied

  23. 23

    sudo permission denied but su grants permission

  24. 24

    Transfer files using scp: permission denied

  25. 25

    Transfer files using scp: permission denied

  26. 26

    scp permission denied after 'hardening' with bastille

  27. 27

    'Permission denied' problem with 'scp' while building blockchain

  28. 28

    Remote: Permission to repo denied at github

  29. 29

    Permission Denied Error when using scp to copy a file to Amazon EC2 instance from Mac OS

HotTag

Archive