0

I have this script that i run to connect to a server and I would like to ask the user for the sudo's password like how "sudo" does it without using sudo. I want it to ask for the password every time the script runs.

#a command to ask for password(sudo's password) before running the command below
*insert here*

sshpass -p $password ssh $user@$ip
momouu
  • 711
  • 4
  • 14
  • [How to get a password from a shell script without echoing](https://stackoverflow.com/q/3980668/3422102) ? – David C. Rankin Jun 16 '21 at 00:52
  • maybe you can replace *insert here* with "sudo".that will let the script ask password – nay Jun 16 '21 at 00:54
  • 3
    Why not just remove `sshpass -p $password` and let `ssh` prompt directly? (and it should be `sshpass -p "$password"`) – jhnc Jun 16 '21 at 01:57
  • Before running the sshpass do `read password` . This s will store the user input to the password variable and then you can use it in the sshpass command. – abhishek phukan Jun 16 '21 at 02:36

0 Answers0