Sudo commands via SSH to VM using Github Actions?

Currently working on a project that’s requiring me to write a GitHub actions .yml.

I have a play where the GitHub Runner can ssh into the Guest OS .VDI (VM) running on the self hosted runner server through a bridged network and run updates as root.
using sshpass

Although I want to avoid using static or dynamic IP addresses for functionality sake.

While adding more adaption to the script to be used as a template for other machines I came across a bug I’ve been trying to fix.

I cannot execute command as sudo through Github actions after using this command:

ssh - p 2222 root@localhost

NAT & portforwarding works (already tied 2222 host OS to port 22 guest OS)

But the guest OS doesn’t like using the github actions pseudo terminal as root, so I would receive an error if I ran any command as root using the github actions main.yml file.

This is the error the Github Runner outputs after attempting to run a sudo command from ssh:

sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper.

any commands that don’t require sudo the runner executes perfectly fine.

I’ve already configured ssh confg to use key based authentication and that operates just fine while manually entering sudo commands into terminal, just not with the Github Actions Runner.

Any advice?!?

I really appreciate it in advance!

I know next to nothing about github actions. But the message is suggesting

echo <password> | sudo -S whatever

or something like

export SUDO_ASKPASS=/usr/local/bin/findpasswordfromsomewhere
sudo -A whatever

Typically for local scripting the findpasswordfromsomewhere runs something like

kdialog --password "sudo wants a password"

which outputs the password on standard output.