-1

i am doing automation the process by bat file.

putty.exe -ssh bhavepatel@10.10.178.140 -pw Winter34! -m C:\Users\BHAVEPATEL\Desktop\tel\tel.txt -t 

In tel.txt file , i want to change the directory ans switch the user.Please see below code in tel.txt file

 cd /apps/denodo/bin 
 sudo -su denodo bash; /bin/bash

Putty prompt with pwd when i swith the user to denodo. How can i pass the password input to bat file?

shellter
  • 36,525
  • 7
  • 83
  • 90
bob3409
  • 33
  • 6

1 Answers1

0

You cannot. Not in an interactive session.

See How to pass the password to su/sudo/ssh without overriding the TTY?

All you can do is to configure sudo not to ask for a password at all. That's the only legitimate approach. To admin that you are actually logging in without typing a password. Instead of secretly automating password typing.

See How to avoid prompt password for sudo?

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992