0

I have some files to upload. Usually to edit anything while logged in the server I must precede the command with sudo. That is known.

How do I send a file then as "admin" instead of "root" when I have disabled root login.

scp path\to\file admin@myaddress.com:/var/www/sitename/public/path/

PERMISSION DENIED

Greg K.
  • 1,005
  • 2
  • 12
  • 20
  • only /tmp/ is available for SCP as of now – Greg K. Oct 25 '11 at 12:01
  • you should edit your question to include this info AND a description its significance to your problem (It is not clear to me), Are you OK with putting the files in /tmp ? Also, setting scp transmissions is a well understood task, have you tried searching here on S.O. or on Superuser.com or via google? Good luck. – shellter Oct 25 '11 at 14:21

3 Answers3

2

In my opinion, either you should give permissions to the admin user or scp your file to /tmp/ and then sudo mv /tmp/yourfile /var/www/sitename/public/path/.

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
1

There is no sudo option when we are using scp command from local to server.

Each user will have upload permission to its own folder in home directory ex. home/xxxxuser so use as below:

scp file_source_here xxxuser@yourserver:/home/xxxuser/

Now you can move file from this folder to your destination.

BSB
  • 2,270
  • 17
  • 26
0

I suggest these two commands as it works in a bash script.

Move the file to tmp as suggested.

scp path\to\file admin@myaddress.com:/tmp

Assuming admin user can do sudo. The ssh option -t allow you to do sudo command.

ssh -t admin@myaddress.com 'sudo chown root:root /tmp/file && sudo mv /tmp/file /var/www/sitename/public/path/'
Martin P.
  • 654
  • 8
  • 18