proper way to sudo over ssh

后端 未结 9 1814
抹茶落季
抹茶落季 2020-11-28 20:33

I have a script which runs another script via SSH on a remote server using sudo. However, when I type the password, it shows up on the terminal. (Otherwise it works fine)

9条回答
  •  感动是毒
    2020-11-28 21:01

    Assuming you want no password prompt:

    ssh $HOST 'echo $PASSWORD | sudo -S $COMMMAND'
    

    Example

    ssh me@localhost 'echo secret | sudo -S echo hi' # outputs 'hi'
    

提交回复
热议问题