Reputation: 515
I'm trying to upload a file from my local desktop to a server and I'm using this command:
scp myFile.txt [email protected]:/opt/nicescada/web
following the structure: scp filename user@ip:/remotePath.
But I get "Permission Denied". I tried using sudo , but I get the same message. I'm being able to download from the server to my local machine, so I assume I have all permissions needed.
What can be wrong in that line of code?
Upvotes: 1
Views: 15341
Reputation: 1407
In case your /desired/path
on your destination machine has write access only for root, and if you have an account on your destination machine with sudo privileges (super user privileges by prefixing a sudo
to your command), you could also do it the following way:
/tmp
:
scp file user@destinationMachine:/tmp
ssh user@destinationMachine
/desired/path
with:
sudo mv /tmp/file /desired/path
In case you have a passwordless sudo setup you could also combine step 2. and 3. to
ssh user@destination sudo mv /tmp/file /desired/path
Another maybe even simpler option would be to use rsync
:
rsync -e "ssh -tt" --rsync-path="sudo rsync" file user@destinationMachine:/desired/path
with -e "ssh -tt"
added to run sudo without having a tty.
Upvotes: 3
Reputation: 1323115
Try and specify the full destination path:
scp myFile.txt [email protected]:/opt/nicescada/web/myFile.txt
Of course, double-check cooluser
has the right to write (not just read) in that folder: 755, not 644 for the web
parent folder.
Upvotes: 2