Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm unable to run a script in linux using plink.exe. I'm using my user x to login and script is under y user, which I need to sudo to y and run it. I was able to at command prompt manually but not through script (for automation).

plink.exe -v -t -l user(x) -pw ****** -ssh hostname "sudo su -y /abc/abc/start.sh"

its asking the password again. i was stuck there

Started a shell/command
[sudo] password for X:
share|improve this question

1 Answer 1

You could configure sudo on your remote host to allow user-X to execute your script without password authentication:

 #/etc/sudoers
 # or new include file in /etc/sudoers.d/

 user-X ALL=(user-Y) NOPASSWD: /abc/abc/start.sh

And normally you don't run sudo to execute su but switch directly to the user you want to run your commands as with something like:

 sudo -u user-Y  /abc/abc/start.sh
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.