ntfy
ntfy copied to clipboard
default-user and default-password in client.yml not working
I've created a file in ~/.config/ntfy/client.yml with this content
default-host: https://push.pablo.tools
default-user: pinpox
default-password: mysupersecretspassword
But the client seems to ingnore the values:
$ ntfy pub --config ~/.config/ntfy/client.yml https://push.pablo.tools/test
{"code":40301,"http":403,"error":"forbidden","link":"https://ntfy.sh/docs/publish/#authentication"}
Using the NTFY_USER
environment variable works, so I know the crendentials are in fact correct:
$ export NTFY_USER=pinpox:mysupersecretspassword
$ ntfy pub test test
{"id":"ix6JqNqNDETe","time":1667306079,"event":"message","topic":"test","message":"test"}
So I looked at the code and it should work. I'll try this out. :thinking:
Note that this leaks/publishes notifications send to a private instance with the 'ntfy cli', to the public instance at https://ntfy.sh/*
, because the configured default-host
is ignored.
Note that this leaks/publishes notifications send to a private instance with the 'ntfy cli', to the public instance at
https://ntfy.sh/*
, because the configureddefault-host
is ignored.
My evil plan to collect user passwords is working :smiling_imp: -- Just kidding. You're right, I should look at this urgently.
@notDavid Can you confirm notifications are being leaked? I just tested it locally, and it seems like default-host
is being used correctly. I think only default-user
and default-password
are being ignored
I figured out what's going on.
The code to use default-user
and default-password
for ntfy **sub**
was released in version 1.28.0.
But the code to use default-user
and default-password
for ntfy **pub**
hasn't been released yet. It's included in (unreleased) version 1.29.0.
Sorry about the (temporary) inconsistency!
As per @wunter8's comment, this was fixed in #431. I'm going to release the code today.
Glad you found it :-)
I don't fully understand by the way, in particular why the setting default-host
does not work either...? But if you say it will be fixed it's fine! 🤗
For the record, this gets send to ntfy.sh instead of my own server:
~ ❯ cat ~/.config/ntfy/client.yml | grep -i 'default-host'
# default-host: https://ntfy.sh
default-host: https://ntfy.xxxxx.nl
~ ❯ ntfy pub mytopic 221112.1951
{"id":"t4xLhs9odPPO","time":1668279076,"event":"message","topic":"mytopic","message":"221112.1951"}
Can you confirm what version of ntfy
you're using? (ntfy -h | tail -n2
)
~ ❯ ntfy -h | tail -n2
ntfy 1.28.0 (d3cfa34), runtime go1.18.6, built at 2022-09-27T16:55:57Z
Copyright (C) 2022 Philipp C. Heckel, licensed under Apache License 2.0 & GPLv2
What happens when you subscribe to a topic? Does it use the configured default-host
? (ntfy sub --trace mytopic
)
❯ ntfy sub --trace mytopic
2022/11/12 20:32:15 DEBUG ntfy.sh/mytopic Subscribing to topic
2022/11/12 20:32:15 DEBUG ntfy.sh/mytopic Listening to https://ntfy.sh/mytopic/json
2022/11/12 20:32:16 TRACE ntfy.sh/mytopic Message received: {"id":"6VVJWtYIBy5a","time":1668281536,"event":"open","topic":"mytopic"}
Alright. Now let's check file permissions: ls -al ~/.config/ntfy/client.yml
❯ ls -al ~/.config/ntfy/client.yml
-rw-r--r-- 1 david staff 1947 Nov 10 11:14 /Users/david/.config/ntfy/client.yml
Oh, you're on Mac? I think the default path for client.yml
on MacOS is ~/Library/Application Support/ntfy/client.yml
. So you could either move your config file there, or specify the path to the config file in the command: ntfy sub --trace --config ~/.config/ntfy/client.yml mytopic
(I just released the v1.29.0, so you should also try that.)
@wunter8 Ahhhh yes that works. Thank you, and sorry for the confusion, i did not realize... 🫣
@binwiederhier Yes, 1.29.9 is working also with the username/password :-)
@wunter8 fyi, I followed the docs here, which is why i put the config file in that location: https://ntfy.sh/docs/subscribe/cli/#install-configure
Perhaps it's a good idea to update that, might save you some time in the future :-)
I found the default path for MacOS here: https://ntfy.sh/docs/subscribe/cli/#subscribe-to-multiple-topics
But I agree we should probably update the docs elsewhere
@wunter8 By the way, wouldn't it make more sense to change this to ~/.config/ntfy/client.yml
, where all other dot files are?
I don't have a single commandline tool which puts their dot files in ~/Library/Application Support/
...