Is there any way to set DEBIAN_FRONTEND=noninteractive
when executing a script remotely via SSH?
Doing so I get this error:
sudo: sorry, you are not allowed to set the following environment variables: DEBIAN_FRONTEND
The reason I want to set DEBIAN_FRONTEND=noninteractive
at exactly this place is because sometimes apt-get dist-upgrade
shows a mask for some user interaction (whiptail). As want to run this script remotely via crontab -e
there is no human to klick or press anything. Hence, I need to turn that off as the script would otherwise remain stuck.
The script I am trying to execute is located on server_one
in /usr/local/bin/perform-update
:
#!/bin/bash
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
sudo apt-get -y autoremove
sudo snap refresh
I try to call it from server_two
using this command:
SERVER_COMMAND="perform-update"
ssh -i $HOME/.ssh/id_rsa backupuser@server_one $SERVER_COMMAND
I have also set the appropriate rights for backupuser
on server_one
in sudo visudo
:
backupuser ALL=(ALL) NOPASSWD: /usr/local/bin/perform-update
backupuser ALL=(ALL) NOPASSWD: /usr/bin/apt-get
backupuser ALL=(ALL) NOPASSWD: /usr/bin/snap