I wanted to use Homeassistant to execute scripts on my Proxmox host. In the past i did this through setting up SSH-connection by logging in as the root. I searched for an alternative solution which would work without SSH. I though something like a rest-api for triggering scripts would exist. And indeed those solutions did exist, but no common-used-solution that everybody is using. This common-used-solution seem to be "SSH". So eventually i chose to use SSH.
- Open a Shell on Proxmox via the Web-gui
- Create the user “homeassistant” with:
useradd --shell /usr/bash --create-home homeassistant
- Navigate in the Proxmox GUI to the "Server View" > “Datacenter”
- Navigate to “Permissions” > “Users”
- Click “Add”
- Give "Username":
homeassistant
- Ensure "Realm":
Linux PAM standard authentication
- Ensure "Enabled":
Checked
- Click the button to create the user
- Select the user
homeassistant
- Choose the button "Password"
- Enter a password
- Open "Homeassistant"
- Install the "SSH-addon"
- Configure the "SSH-addon" to accept a password by providing a password
- Configure the "SSH-addon" to work on port: 22
- Start the SSH-addon
- Choose the the button "OPEN WEB-UI"
- In the console crreate directory:
mkdir -p /config/key/
- Generate keypair:
ssh-keygen -t rsa -b 4096 -f /config/key/id_rsa
- Copy the public key to the Proxmox-host:
ssh-copy-id -i /config/key/id_rsa.pub homeassistant@192.168.178.2
(192.168.178.2 is the IP# of my Proxmox-host) - Accept the fingerprint of the remote host (SSH addon)
- Enter the password of the user “homeassistant” you created on the Proxmox-host
In the shell of the Proxmox-host as the root user:
- Create a usegroup which can run "ryzenadj":
groupadd ryzenadj
- Make the user "homeassistant" member of the usergroup:
usermod -aG ryzenadj homeassistant
- Create a sudoers-file to allow for running "ryzenadj" with "sudo" without requiring a password:
nano /etc/sudoers.d/ryzenadj
- Put in this file:
## Members of the ryzenadj group may gain some privileges
%ryzenadj ALL=(ALL) NOPASSWD: /usr/local/bin/ryzenadj
I installed the remote command line integration via HACS. In homeassistant add this yaml:
remote_command_line:
tdp_low:
ssh_user: homeassistant
ssh_host: 192.168.178.2 < IP# of my Proxmox host
ssh_key: /config/key/id_rsa
command_timeout: 10
command: "sudo ./ryzenadj --stapm-limit=1000 --fast-limit=1000 --slow-limit=1000 --tctl-temp=90 --power-saving > /dev/null"
tdp_high:
ssh_user: homeassistant
ssh_host: 192.168.178.2
ssh_key: /config/key/id_rsa < IP# of my Proxmox host
command_timeout: 10
command: "sudo ./ryzenadj --stapm-limit=45000 --fast-limit=45000 --slow-limit=45000 --tctl-temp=90 --max-performance > /dev/null"