I have home assistant installed on my raspi 4 and have installed SSH. In text editor when I go to config/configuration.yaml it gives me an error “permission denied”. New to this so need your help please.
In which text editor?
Assuming you added the ssh add-on. Also assuming you set your configuration.
Config for ssh should look something like this:
authorized_keys: []
apks: []
password: YourPasswordHere
server:
tcp_forwarding: false
command assuming you are login in from a linux box
ssh [email protected] <---- your Home Assistant ip address here
when prompting for password you use the password from the configuration.
I use nano but vm works as well.
root is required because the owner and group of the directory is set to root and mode of directory is set 755 permission meaning only owner can write to directory.
Thanks for prompt reply , My config for SSH is as follows. I than open terminal from the side bar …see below.
ssh:
username: hassio
password:
authorized_keys:
sftp: false
compatibility_mode: false
allow_agent_forwarding: false
allow_remote_port_forwarding: false
allow_tcp_forwarding: false
zsh: true
share_sessions: false
packages: []
init_commands: []
c++ text editor even tried windows text editor
I would change your password and edit your post to remove it and the authorized keys.
I would try the following to see if it helps.
Go to the terminal
- cd /
- chmod -R 766 ./config
This will give all users read and write privilege. It exposes you to a little more risk but it adds a great deal of convenience.
Thank you for reply sir. Your advise worked with the chmod command. Have been trying for days and you saved me… Just one more question do I add the below in my config.yaml file for my sonoff switches to work?? I tried this from file editor and it did not work.
switch:
- platform: template
switches:
ewelink_virtual_switch:
turn_on:
service: switch.turn_on
turn_off:
service: switch.turn_off
Your indentation is off. Yaml is very sensitive to indentation. It needs to be :
switch:
- platform: template
switches:
ewelink_virtual_switch:
turn_on:
service: switch.turn_on
turn_off:
service: switch.turn_off
And if you had switch: already, it can only exist one time.
I would also suggest that you use !include and move to a separate file if you are going to have multiple switches.
In configuration.yaml
switch: !include switch.yaml
Then create a file in ./config by using touch
touch switch.yaml
open switch.yaml with your editor of choice and pate @francisp code in the file
- platform: template
switches:
ewelink_virtual_switch:
turn_on:
service: switch.turn_on
turn_off:
service: switch.turn_off
Doing this will keep your configuration.yaml much cleaner.
Jesus, file permissions are set by experts. I recommend NOT to change them unless you really know what you are doing!
@nickrout So you should accept a system that is not working versus changing the permissions to get it to work? I don’t understand the reasoning behind this. Others can pipe in but Linux permissions are pretty straight forward. owner, group and world have permission to rwx. The advice I gave simply opened up write access to other users besides root.
I don’t believe that permissions are set by experts. They are part of the control on how you manage a linux/unix system.
Hi J thanks for all the help finally got the switches working after struggling for many days. Bless you and thanks once again.
Glad to help and provide some pay back for all the help I have received from others. I should also point out that if you wish to change it back to the way the system originally was the commands are:
- cd /
- chmod -R 744 ./config
The -r is to recursively change all directories under config and 744 means root has rwx privilege, group has read only, and all other users have read only privilege. If you want to give the group write privilege the number would be 764.
man chmod
says:
-R, --recursive
change files and directories recursively
This would give all of your config files u+x
. Marking config files as executable is not a good thing…
Directories need to have the execute permission set in order to allow being cd
d into, though.
This means that you’ll probably need two commands to set the permissions correctly.
Maybe something like this to go back to the original permissions:
find /config -type d -exec chmod 755 '{}' ';'
find /config -type f -exec chmod 644 '{}' ';'
To allow everyone to write to your config directory:
find /config -type d -exec chmod 777 '{}' ';'
find /config -type f -exec chmod 666 '{}' ';'
I wouldn’t necessarily recommend this, though.
Leave the file permissions as is. If you cannot alter them without becoming another user, it is a good reminder that care is needed. Files are writable by root because they are important.
chmod
also have an “expressive” mode.
chmod -R u+rX
(note the capital x) gives read and “enter” permissions on directories, but not executable on plain files.
In HA as a container, it’s just plainly because HA runs as root in the container, tbh, which is bad in the first place.
Fixed the -r to -R. I always do that typo - Don’t know why. When I checked the install when I did this on my system the files were 744. I kept the same permissions for user. Not saying it is correct only that is what I had.