TheMountainThatCodes
TheMountainThatCodes

Reputation: 217

Why am i getting permission denied in SCP for a local file as root?

I am trying to copy a file f I created on my local machine to a remote one (to the home directory of my user there) by SCP. I have root privileges on my machine, but after executing:

scp f [email protected]:/  

I get:

scp: /f: Permission denied  

Also

ls -l f  

returns:

-rw-rw-r--  

I'm confused, shouldn't i be able to copy it as root? Or even without it given the permissions?

Upvotes: 0

Views: 6050

Answers (3)

F. C.
F. C.

Reputation: 46

I encountered the same problem when using the scp command. I find the failure attribute to the duplicated file in the target folder. After deleting/renaming that file, the command becomes effective. That is, after changing to the directory of the file, use the command scp filename [email protected]:~/target/dir.

Upvotes: 0

salah
salah

Reputation: 11

to resolve this error, assign Read-write-execute (rwx) permission to everyone.

$ sudo chmod 777 "path-to-your-remote-directory"

Link : https://cloudlinuxtech.com/scp-permission-denied/

Upvotes: 1

Jakuje
Jakuje

Reputation: 25956

This is error from remote side saying that you don't have write access to the / of the remote.edu. I guess you don't want to copy the file to the /, but to the home directory:

scp f [email protected]:

SCP is a simple tool and does not have very advanced error reporting features and the messages might not be so straightforward as expected. But if you run the same command with -vvv switches, it should tell you more information what is going on behind the scenes and where the error is actually coming from.

Upvotes: 2

Related Questions