How to perform SCP as a Sudo user

Posted by Ramesh.T on Super User See other posts from Super User or by Ramesh.T
Published on 2009-12-24T04:41:02Z Indexed on 2010/04/02 11:03 UTC
Read the original article Hit count: 585

Filed under:
|

What is the best way of doing SCP from one box to the other as a sudo user. There are two servers

Server A

10.152.2.10

/home/oracle/export/files.txt

User : deploy

Server B

10.152.2.11

/home/oracle/import/

User : deploy
Sudo user : /usr/local/bin/tester

all i want is to copy files from server A to Server B as a sudo user...

In order to do this, first i normally login as deploy user on the target server and then switch as a sudo user without password.

after that SCP to copy file, this is the normal way i perform this activity...

In order to auotmate i have written script

#!/bin/sh
ssh deploy@lnx120 
sudo /usr/local/bin/tester "./tester/deploy.sh"

I have generated the private key for deploy user, so it allows me to login as deploy user without password. afterthar the sudo command is executed it will switch the user to tester...

after that nothing happens.. i mean the script is not getting executed ... is there any way to accomplish this in a different way...

© Super User or respective owner

Related posts about scp

Related posts about sudo