1

I'm trying to copy a file from my local machine macosx 10.11.6 to a remote server (digital ocean droplet) ubuntu 18.04 using scp. I tried

scp -r /path/to/local/file username@ipaddress:/path/to/folder/where/to/copy

and I got permission denied.

I ssh into the server cd /path/to/folder/where/to/copy and test with touch index.txt and got permission denied.

I tried to touch index.txt with sudo which worked after input the password.

I tried install and use sshpas

sshpass -p 'mypassword' scp -r /path/to/local/file username@ipaddress:/path/to/folder/where/to/copy

And I got permission denied again.

What is the correct way to copy that file from local to the remote server passing the user password?

Daniel
  • 3,312
  • 1
  • 14
  • 31
Tanuki
  • 183
  • 4
  • 11
  • Please [edit] your question to include the exact error which scp is printing. Don't paraphrase it. – Kenster Feb 27 '19 at 20:57

2 Answers2

0

It sounds like your remote server user doesn't have write permissions to your destination directory, that's why the touch fails.

You can either copy the file to somewhere else (your user's home?) or modify the destination folder's permissions with sudo and chmod to allow your user to write to the destination directory.

  • Thank you for your reply @Lucas Lavandeira, I did ls -ld and got lrwxrwxrwx so it seems that I have the necessary permissions If i'm not mistaking. – Tanuki Feb 27 '19 at 19:21
0

As mentioned here SSH SCP Local file to Remote in Terminal Mac Os X , I had to do it in two times. scp -r /path/to/local/file username@ipAddress:/home/username then ssh username@ipAddress sudo mv file path/to/destination/folder

Tanuki
  • 183
  • 4
  • 11