Skip to content

Unable to natively execute sudo privileged commands #29

@sigmaenigma

Description

@sigmaenigma

Hello. I found an issue on line 49 where the command does not include an option to run a command with sudo privileges. I modified your init.py script in HomeAssistant and verified this works. I can do a formal merge request if you'd like:

# If sudo is in the command, pass the password to execute
if 'sudo' in command:
    _, stdout, stderr = client.exec_command(f'echo {password} | sudo -S {command}')
    password = '**redacted**' # Redacting password for the response
else:
    _, stdout, stderr = client.exec_command(command)

I was trying to perform a 'sudo shutdown -h now' or 'sudo apt update' and noticed this failed but I knew I was successfully logging in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions