![]() ![]() That’s it! We now have key pairs created and transferred it to the remote machine. Next we are going to copy the public key to our remote machine (just change the remote_hostname to proper IP address or hostname of the remote linux PC): ssh-copy-id -i /config/ssh_keys/id_rsa_homeassistant.pub homeassistant password to the remote machine will be queried at this point, so enter it. In above lines we first create a directory for our ssh keys, because Home Assistant is run in a docker container and does not have visibility to default /root/.ssh folder at all. ![]() If fulfilled with password the SSH connection will require both key and password and can’t be used for remote commands by home assistant. When a password is queried, leave it empty. Ssh-keygen -t rsa -f /config/ssh_keys/id_rsa_homeassistant Start by creating the RSA public and private key pairs by typing mkdir /config/ssh_keys Next we’ll going to SSH into Home Assistant (you need to have SSH add-on installed in home assistant). Oh, the SSH connection to your remote machine can now be closed, no need to configure that part anymore. Now save and exit and we’re good to move to the next section. Remember not to delete anything from the file, just add the above line in it. Homeassistant ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbin/reboot, /sbin/shutdown You really don’t want to mess it up □ Now lets add the access right for our newly created homeassistant user by adding line below user privilege specification # User privilege specification The sudoers file should be now open with visudo that verifies syntax of the file. That can be done by editing the sudoers file. Now that we have our HA user created we need to grant it an access to reboot the machine. So, let’s create a new user for our Home Assistant instance by SSH into remote machine and typing sudo adduser homeassistantįill out the information requested including password, you’ll need it later. Normally shutting down a linux machine from command line requires a root user access and of obviously we don’t want to give our Home Assistant full root access in case of e.g. Configuring the remote PCįirst we need to configure the remote linux pc to support shut down in a secure way. You should also know the IP and MAC addresses of your Remote PC. I’m assuming you’re even a bit familiar with linux shell and have already basic SSH access to your remote machine and home assistant. Public and private key pairs can be though of as a key (local machine) and a lock (remote machine) that work together for security. In this guide I’m using remote shell commands through SSH and password-less SSH connection is achieved by using public and private key pairs. The shut down procedure is a bit more complicated than the start up. we’ll get back to this when configuring the Home Assistant at the end of this article. So, to get the startup working, find a manual of your remote PC motherboard and find a way to enable WoL or just enter BIOS and explore □ WoL needs to be enabled from computers BIOS settings. WoL is a ethernet computer networking standard that allows a computer to be turned on or awakened by a network message. Start upįor the startup we are going to be using Wake-On-Lan (WOL). Since it’s not ‘that simple’ I decided to write a quick guide about it. The PC is only required once or twice in a month so I don’t want to keep it up 24/7 just to consume electricity. I’m currently having a need to start and stop my headless VDR/streaming PC when needed. Sometimes there’s a need to remote start and stop a Linux PC through Home Assistant. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |