I would like to create a simple script to download and install a program over ssh.
#!/bin/bash
echo "Welcher Rechner?"
read nummer
echo "Verbinde zu APC "$nummer
apc=apc$nummer.local
sshpass -f .pass_file scp $HOME/autoconfig/.filius_update.sh dvadmin@$apc:$HOME/
sshpass -f .pass_file scp $HOME/autoconfig/filiusurl dvadmin@$apc:$HOME/
sshpass -f .pass_file scp $HOME/autoconfig/.pass_file.sh dvadmin@$apc:$HOME/.pass_file.sh
sshpass -f .pass_file ssh dvadmin@$apc 'export SUDO_ASKPASS=${HOME}/.pass_file.sh; sudo -A chmod +x ./.filius_update.sh && ./.filius_update.sh'
sshpass -f .pass_file ssh dvadmin@$apc 'export SUDO_ASKPASS=${HOME}/.pass_file.sh; sudo -A rm ./.pass_file.sh && rm filius.deb && rm filiusurl && rm .filius_update.sh'
But the terminal send me an error that I have to configure askpass:
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: A password is required
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper
sudo: A password is required
I don't understand what did I wrong.
Thank you in advice.
sudo
in a remote shell without a terminal device ... As a security featuresudo
requires the password to be intered/transmitted through a terminal/virtual terminal device ... See for example similar sudo: unable to allocate pty: No such device ... Also see the part aboutsudo -S
here: https://askubuntu.com/a/1465841 – Raffa May 10 '23 at 14:41SUDO_ASKPASS
can work in a remote shell like that ... I haven't tested it to confirm, but in theory it shouldn't work that way(at least not with available normal methods/mechanisms) ... You most likely need to look into alternatives. – Raffa May 10 '23 at 15:03