Login logging

I sometimes get the notification that there was a failed login attempt. But after that you don’t know it. Did they succesfully login after that? Could there be a kind of of Login Log where you can see what IP was loggjng in, what user they were logging in to and if it was successful or not.

Don’t forget to vote for your own feature request.

From looking at the source code, it seems like this should already be possible. A message with level DEBUG is logged on a successful login.

You’ll need to configure your logger to not ignore debug messages from homeassistant.components.http.ban.

1 Like

This only logs a successful login after it has previously failed, and also resets the failed login counter back to zero for that IP failure…

I was trying to determine the IP I was connecting from (don’t ask…it’s a complicated setup involving Todyl SGN Connect tunneling for a project I am working on from home) so I could add it to my trusted networks. The only option I could think of was to trigger 5 login failures and then I used SSH to see the IP in ip_bans.yaml, deleted the entry, added the IP to known_networks + trusted_users and did ha core restart.

We need a better way!

This logging and notification was possible with this component, and it was very useful as it is a security concern that someone can login into your HA instance without you noticing: GitHub - custom-components/authenticated: A platform which allows you to get information about sucessfull logins to Home Assistant.

Unfortunally for some reason the component was deprecated last year and it doesn´t seem to be any alternative available.

Given how important HA is to the monitoring and control of our homes, I think it should be one of the most important security features to be able to see who logs in, who tries to log in, when and from where. I’ve enabled 2FA for myself but my wife, with restricted access, doesn’t use 2FA. So there’s a hole there that’s hard to plug but I’d at least like to know if she has logged on when she hasn’t (ie someone has guessed her password).

I was looking for this as well. Seems like there are a number of forks of the original. One that seems recently updated and that I was able to install through HACS is:

@jabronimus Is it working for you on the latest version of Home Assistant? (2024.7.2)

I just get an ‘unknown’ sensor now, where it was working before.

Any idea why the persistent notification time is utc and not my local time?

New successful login
    **IP Address:**   192.168.200.169
    **Username:**    My Username
    
    **Hostname:**   192.168.200.169
    
    
    **Login time:**   2024-11-08 12:09:37

Every timestamp stored in the HA database is recorded in UTC time. It’s a common standard used in most applications to ensure consistency.

If you want it to be shown in local time, create a template sensor which converts it.

How would you create a template sensor for a persistent notification?