Score:1

SUDO_ASKPASS not working

ch flag

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.

Raffa avatar
jp flag
You are running `sudo` in a remote shell without a terminal device ... As a security feature `sudo` 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](https://askubuntu.com/q/1449413) ... Also see the part about `sudo -S` here: https://askubuntu.com/a/1465841
Raffa avatar
jp flag
On the other hand, I'm not sure even `SUDO_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.
Score:0
ch flag

now I use

sshpass -f .pass_file ssh dvadmin@$apc '$HOME/.pass_file.sh | sudo -S chmod +x ./.filius_update.sh && ./.filius_update.sh'

and it finally works :) I don't know why my old way doesn't work anymore but I've a solution and now I have to edit my other scripts :/

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.