[GH-ISSUE #460] default-user and default-password in client.yml not working #353

Closed
opened 2026-05-07 00:23:22 +02:00 by BreizhHardware · 20 comments

Originally created by @pinpox on GitHub (Nov 1, 2022).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/460

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"}
Originally created by @pinpox on GitHub (Nov 1, 2022). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/460 I've created a file in ~/.config/ntfy/client.yml with this content ```yml 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"} ```
BreizhHardware 2026-05-07 00:23:22 +02:00
Author
Owner

@binwiederhier commented on GitHub (Nov 2, 2022):

So I looked at the code and it should work. I'll try this out. 🤔

<!-- gh-comment-id:1301057085 --> @binwiederhier commented on GitHub (Nov 2, 2022): So I looked at the code and it _should_ work. I'll try this out. :thinking:
Author
Owner

@notDavid commented on GitHub (Nov 10, 2022):

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.

<!-- gh-comment-id:1310055289 --> @notDavid commented on GitHub (Nov 10, 2022): 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.
Author
Owner

@binwiederhier commented on GitHub (Nov 11, 2022):

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.

My evil plan to collect user passwords is working 😈 -- Just kidding. You're right, I should look at this urgently.

<!-- gh-comment-id:1311672890 --> @binwiederhier commented on GitHub (Nov 11, 2022): > 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. My evil plan to collect user passwords is working :smiling_imp: -- Just kidding. You're right, I should look at this urgently.
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

@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

<!-- gh-comment-id:1312535922 --> @wunter8 commented on GitHub (Nov 12, 2022): @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
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

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!

<!-- gh-comment-id:1312541659 --> @wunter8 commented on GitHub (Nov 12, 2022): I figured out what's going on. The [code](https://github.com/binwiederhier/ntfy/commit/9d0231ea07768edf2dbe7ffc42c88263a7abaf0e) to use `default-user` and `default-password` for `ntfy **sub**` was released in version 1.28.0. But the [code](https://github.com/binwiederhier/ntfy/commit/85eb9160d81aef0ed4649f709d27da6e9393815c) 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!
Author
Owner

@binwiederhier commented on GitHub (Nov 12, 2022):

As per @wunter8's comment, this was fixed in #431. I'm going to release the code today.

<!-- gh-comment-id:1312548308 --> @binwiederhier commented on GitHub (Nov 12, 2022): As per @wunter8's comment, this was fixed in #431. I'm going to release the code today.
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

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! 🤗

<!-- gh-comment-id:1312549486 --> @notDavid commented on GitHub (Nov 12, 2022): 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! 🤗
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

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"}
<!-- gh-comment-id:1312550771 --> @notDavid commented on GitHub (Nov 12, 2022): 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"} ```
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

Can you confirm what version of ntfy you're using? (ntfy -h | tail -n2)

<!-- gh-comment-id:1312551713 --> @wunter8 commented on GitHub (Nov 12, 2022): Can you confirm what version of `ntfy` you're using? (`ntfy -h | tail -n2`)
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

~ ❯ 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
<!-- gh-comment-id:1312551959 --> @notDavid commented on GitHub (Nov 12, 2022): ``` ~ ❯ 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 ```
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

What happens when you subscribe to a topic? Does it use the configured default-host? (ntfy sub --trace mytopic)

<!-- gh-comment-id:1312554915 --> @wunter8 commented on GitHub (Nov 12, 2022): What happens when you subscribe to a topic? Does it use the configured `default-host`? (`ntfy sub --trace mytopic`)
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

❯ 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"}
<!-- gh-comment-id:1312556617 --> @notDavid commented on GitHub (Nov 12, 2022): ``` ❯ 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"} ```
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

Alright. Now let's check file permissions: ls -al ~/.config/ntfy/client.yml

<!-- gh-comment-id:1312557048 --> @wunter8 commented on GitHub (Nov 12, 2022): Alright. Now let's check file permissions: `ls -al ~/.config/ntfy/client.yml`
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

❯ ls -al ~/.config/ntfy/client.yml
-rw-r--r--  1 david  staff  1947 Nov 10 11:14 /Users/david/.config/ntfy/client.yml
<!-- gh-comment-id:1312557317 --> @notDavid commented on GitHub (Nov 12, 2022): ``` ❯ ls -al ~/.config/ntfy/client.yml -rw-r--r-- 1 david staff 1947 Nov 10 11:14 /Users/david/.config/ntfy/client.yml ```
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

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

<!-- gh-comment-id:1312559528 --> @wunter8 commented on GitHub (Nov 12, 2022): 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`
Author
Owner

@binwiederhier commented on GitHub (Nov 12, 2022):

(I just released the v1.29.0, so you should also try that.)

<!-- gh-comment-id:1312559900 --> @binwiederhier commented on GitHub (Nov 12, 2022): (I just released the v1.29.0, so you should also try that.)
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

@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 :-)

<!-- gh-comment-id:1312563787 --> @notDavid commented on GitHub (Nov 12, 2022): @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 :-)
Author
Owner

@notDavid commented on GitHub (Nov 12, 2022):

@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 :-)

<!-- gh-comment-id:1312564950 --> @notDavid commented on GitHub (Nov 12, 2022): @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 :-)
Author
Owner

@wunter8 commented on GitHub (Nov 12, 2022):

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

<!-- gh-comment-id:1312565411 --> @wunter8 commented on GitHub (Nov 12, 2022): 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
Author
Owner

@notDavid commented on GitHub (Nov 13, 2022):

@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/...

<!-- gh-comment-id:1312661409 --> @notDavid commented on GitHub (Nov 13, 2022): @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/`...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#353
No description provided.