0

I have simple bash script:

#!/bin/bash
sudo etherwake -i enp0s31f6 -D -b xx:xx:xx:xx:xx:xx

I have set also SUID bit and root as owner:

-rwSr-xr-x 1 root root 64 Aug 19 04:23 startPC.sh

If I run it from terminal as normal user, it execute normally. When I run it from SSH command as parameter, it asks for password for sudo:

ssh lukas@server 'Scripts/startPC.sh'
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper

Is there any way how to work around this? Thanks!

  • Also: usually [setuid is irrelevant for scripts](https://unix.stackexchange.com/q/364/108618). – Kamil Maciorowski Aug 19 '21 at 08:36
  • adding -t parameter does not work. I would like to execute the script remotely without entering password, just using user's private key for the SSH authentication. This approach works for me, but I have to connect to server via SSH and manually execute the script. It will ran and no password is required. When I try to execute it directly as SSH parameter, it asks for password. – Lukáš Michalec Aug 19 '21 at 08:44
  • oh my bad, I found the issue. – Lukáš Michalec Aug 19 '21 at 08:45

0 Answers0