Ssh copy id with yes and password1/1/2024 ![]() replace ‘ #PasswordAuthentication yes’ with ‘PasswordAuthentication no’ replace ‘ #PubkeyAuthentication yes’ with ‘PubkeyAuthentication yes’ Open “\ProgramData\ssh\sshd_config” and change the following:.Open a Powershell as Administrator and run the following to set the proper permissions to the keys file: Get-Acl "$env:ProgramData\ssh\ssh_host_dsa_key" | Set-Acl $env:ProgramData\ssh\administrators_authorized_keys Open the “/config/ssh_keys/id_rsa.pub” key that you generated on Home Assistant with File Editor and copy the key into “\ProgramData\ssh\administrators_authorized_keys”Ħ. On your windows machine (the machine you want to connect to without a password), navigate to “\ProgramData\ssh” and create a file “administrators_authorized_keys” (I had to create it on my desktop and copy it in because of permissions)ĥ. Go to “Containers”, and under “Quick Actions”, open a console for “homeassistant”Īnd save them to “/config/ssh_keys/id_rsa”Ĥ. ![]() This lets you access the HA Dockers Containers. Here are the steps for anyone who is interested. So you need to console into the Home Assistant Docker container and generate the keys from there, not from the Home Assistant OS Terminal. That’s why I can SSH without password from terminal but get errors on the shell_command. Once I realized the Home Assistant OS runs on containers, i knew what to do… The issue is I’m generated the keys from the root OS, not from the docker container that the shell_command runs through. You won’t have access to that directory from a Home Assistant shell command (it’s running in its own container), so that’s why you need to put it somewhere else (like /config/ssh_keys) and point to it with -i. If you’re able to run ssh without pointing to the private key ( id_rsa), that means that there’s a valid private key in /root/.ssh. If that folder is too permissive, it will deny access. ssh folders on both the local and remote machines so that they’re only readable by the owner - chmod 700 in Unix/Linux/everything else speak. The only other thing that I can think of is that you need to protect the. It’s trivial for everything but, apparently, a Windows machine. As you can see from that output, you’re giving it the private key and it derived the name of the public key from it - id_rsa.pub - to copy over. It looks like the SSH server on your windows machine isn’t behaving as ssh-copy-id expects, so you’d have to copy the public key over manually (as you did before). Most folks use IOTLink for the stuff you’re doing. I’m able to connect without a password just fine with just a standard ssh command! HOWEVER, it doesn’t work when it runs through the shell_command script, it just errors saying: “Permission Denied (publickey, keyboard-interactive)” I was eventually able to get it working through the terminal in Home Assistant by adding the HA’s public key to my Windows Machine’s authorized keys in “C:\Users\username.ssh\authorized_keys” as outlined in this video ( Windows 10 SSH with Public Key Authentication - YouTube) However it still asks for the password when I test it in the SSH terminal on the Home Assistant. So my shell command is: ssh -i /config/ssh_keys/id_rsa -o StrictHostKe圜hecking=no "powercfg -h off & rundll32.exe powrprof.dll,SetSuspendState 0,1,0" I generated a key using “ssh-keygen” on windows and copied the contents of the id_rsa to a file in my config “/config/ssh_keys/id_rsa” as outlined in this post ( Power on / off NAS by using WOL and SSHPASS - #2 by Lucan). I’m trying to figure out the SSH keys so I can have the SSH command trigger without needing my Windows Machine’s password. I’m trying to send a command to my PC to sleep over SSH from my Home Assistant (installed Home Assistant OS on Raspberry Pi 4). I’ve been trying all day to get this to work with no luck.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |