2 Prepare your computer
Mathieu Broillet edited this page 2024-08-30 11:23:06 +02:00

Configure Linux-running Computer 🐧

Automatic Configuration

Run the following command on your Linux-running computer to automatically configure SSH and sudoers:

Warning

The script must be run with sudo (except if your user is root).

sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/M4TH1EU/HA-EasyComputerManager/main/.github/wiki/script-auto-config-linux.sh)"

Note

If you don't feel comfortable running a script from the internet, you can check it out here or follow manual instructions below.


Manual Configuration

1. Enable SSH Server

Make sure your computer has a working SSH server. This integration has been tested with OpenSSH. Use the following commands on most systems:

sudo systemctl enable --now sshd

2. Configure sudoers

Allow your user account to run specific sudo commands without a password prompt. This step is crucial for Home Assistant to execute necessary commands. Follow these steps:

  • Open a terminal and run:

    visudo
    
  • Append the following lines to the end of the file:

    # Allow your user to execute specific commands without a password
    username ALL=(ALL) NOPASSWD: /sbin/shutdown, /sbin/init, /usr/sbin/pm-suspend, /usr/sbin/grub-reboot, /usr/sbin/grub2-reboot, /usr/bin/cat /etc/grub2.cfg, /usr/bin/cat /etc/grub.cfg
    

    ⚠️ Replace username with your actual username.

3. Firewall Configuration

It may be necessary to allow port 22 (SSH) in your firewall settings.

4. XHost Configuration

To allow this integration to start GUI applications from an SSH connection (without a display), you have to configure XHost.

Create a file named EasyComputerManager-AutoStart.desktop in /home/<your username>/.config/autostart with the following content:

[Desktop Entry]
Type=Application
Name=$DESKTOP_ENTRY_NAME
Exec=sh -c 'xhost +<your homeassistant ip>; xhost +localhost'
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true

⚠️ Replace <your homeassistant ip> with the IP address of your Home Assistant instance.

You'll have to reboot your computer to apply the changes or manually run the command from the 'Exec' line.


Configure Windows-running Computer 🪟

Automatic Configuration

Run the following command on your Windows-running computer to automatically configure SSH and sudoers:

Set-ExecutionPolicy Unrestricted -Force;
Invoke-WebRequest -Uri https://raw.githubusercontent.com/M4TH1EU/HA-EasyComputerManager/main/.github/wiki/script-auto-config-windows.ps1 -OutFile windows.ps1; .\windows.ps1

Note: If you don't feel comfortable running a script from the internet, you can check it out here.


Manual Configuration

1. Install OpenSSH Components

Follow these steps to install the OpenSSH components on a Windows computer:

  1. Open Settings and go to Apps, then Optional Features.
  2. Check if OpenSSH is installed. If not, select "Add a feature" at the top.
  3. Find and install both the OpenSSH Client and OpenSSH Server.
  4. Confirm that OpenSSH is listed in Apps and Optional Features.
  5. Open the Services desktop app (type services.msc in the Start menu).
  6. Double-click "OpenSSH SSH Server" in the details pane.
  7. On the General tab, set the Startup type to Automatic and select Start to activate the service.

For detailed instructions, refer to Microsoft's guide.

2. Firewall Configuration

Ensure that port 22 (SSH) is allowed through the Windows firewall. This step may be handled automatically by following the instructions above.


🖧 Configure Dual-Boot Computer

To manage a dual-boot computer, configure both Windows and Linux using the respective sections above. Ensure that the same username and password are used on both systems.

Note: Don't forget to check the "Dual boot system" checkbox when adding your PC to Home Assistant.


Why Not Use SSH Keys? 🔑

While SSH keys provide enhanced security, this integration uses passwords for simplicity. In the future, the option to use SSH keys may be added based on user feedback.