0

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:
masegaloeh
  • 17,978
  • 9
  • 56
  • 104
sagar
  • 1
  • 1

1 Answers1

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
HBruijn
  • 72,524
  • 21
  • 127
  • 192