I'm trying to upload a file from my local desktop to a server and I'm using this command:
scp myFile.txt cooluser@192.168.10.102:/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?
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.