Your Own Notification Server (film, 23 minutes)
In his latest video, NetworkChuck discusses a powerful push notification tool known as NTFY. This tool is a free, open-source platform that users can self-host. NTFY allows users to receive notifications in various contexts, such as when an nmap scan completes, a file upload finishes, or a file download is completed. With features like adding emojis, attachments, and even allowing actions in response to notifications, it becomes incredibly useful. NetworkChuck encourages viewers to leverage NTFY by adding quick commands into the terminal and monitoring various events, whether locally or in the cloud.
The first significant step that NetworkChuck takes is to set up an NTFY server either in the cloud or on a personal device such as a Raspberry Pi. In the video, he walks through the configuration process and the installation of the mobile NTFY application on Android and iOS to better receive push notifications. With NTFY, users can easily customize notifications and subscribe to specific topics like "coffee." Proper configuration also requires creating a configuration file, which NetworkChuck meticulously describes step by step.
One of the key aspects of NTFY is its versatility and ease of use. As NetworkChuck points out, the simplicity of this application allows it to be tailored for various use cases, enabling integration of notification reception with any process or script, both in the terminal and in task scheduling. He also illustrates how NTFY can assist with everyday tasks, like program updates or server management.
Additionally, NetworkChuck emphasizes the importance of cloud services such as Linode for hosting the NTFY server, which allows users to access notifications from anywhere. With the simple management of a virtual machine in Linode, setting up access to the server can be done rapidly, making this process even more user-friendly. Through integration with Cloudflare, users can also securely expose their notifications externally.
Finally, NetworkChuck highlights the impressive statistics surrounding the video. At the time of writing, the video has been viewed 979654 times and has accumulated 27188 likes. Viewers have followed through with all the steps of installing and configuring NTFY, showcasing significant interaction and interest in the topic among the audience. Therefore, it's worth diving deep into the possibilities that NTFY offers and sharing any ideas in the comments section below the video.
Toggle timeline summary
-
Introduction to NTFY - command line push notifications and its capabilities.
-
Setting up NTFY to receive notifications while performing tasks.
-
Overview of NTFY's features, including emojis and attachments.
-
Instructions on setting up an NTFY server, both in the cloud and locally.
-
Introduction to using Linode for cloud machine setup.
-
Completing cloud server setup and SSH access.
-
Installing Docker on local system.
-
Accessing and managing NTFY web interface.
-
Discussing public vs private accessibility of the NTFY server.
-
Installing the NTFY app on mobile devices for notifications.
-
Using Curl to send notifications in NTFY.
-
Managing subscriptions to topics in NTFY.
-
Creating configuration files for enhanced NTFY features.
-
Testing push notifications across devices.
-
Setting up Cloudflare tunnels for home network access.
-
Examples of practical uses for NTFY notifications.
-
Summarizing the capabilities and resources for NTFY.
-
Encouragement to explore creative uses of NTFY and community engagement.
Transcription
command line push notifications. This is crazy. I check this out. It's so powerful. Let's say I'm running an end map scan that could take a minute or I'm copying a large file in windows or I'm downloading a YouTube video on Mac. I don't want to sit here and wait for all this to happen. I've got stuff to do like make more coffee. So I'll add one more command and then go make some coffee and watch what happens. That's just a few examples of the amazing notification tool called NTFY or notify. It's free open source and you can self host it. And it's stupid how much it can do. Emojis, attachments, scheduling, phone calls, and even actions. You can do things in response to your notifications. It's crazy power. So in this video, I'm going to show you how to set this up yourself. It will take about five minutes and here's what we're doing. We'll set up an NTFY server in the cloud or in your house. I'll show you both. This can even run on a Raspberry Pi. You'll then install the free NTFY app on Android or iPhone. So you can get those sweet, sweet push notifications. And it's not just mobile. It can go to browser, your command line, and a number of services that you can connect to it. And that's pretty much it. It's kind of easy. And once we're done, I'll show you some really fun ways we can use this. It's kind of addicting. So get your coffee ready and let's read a push notification joke from chat GPT. Why did the push notification go to school? Because it wanted to be a little more alert. Actually, it wasn't that bad. All right, let's get started. Step one, the setup, the install. As I mentioned earlier, I'll show you how to do it both on the cloud or in the cloud and at your house on prem on a Raspberry Pi, wherever you want to put it. Now, the beautiful part about this is that both setups are pretty much the same because we're going to be using Docker. You probably saw that coming, right? Docker is my favorite. Now, if you don't know what Docker is, that's fine. I'll show you how to use. And it's amazing. But first let's go ahead and get our cloud machine set up. And for the cloud, we're using my favorite provider in the entire world, Linode, which is now owned by Akamai, making them more powerful. Now, Linode is the sponsor of this video and also the place where I store all of my projects, including this one. And when I say all of my projects, look at everything I have running right now. It's the best because you can literally get a virtual machine set up in about three minutes, actually two minutes. Let me show you. Once you get signed up, when you go to linode.com forward slash network, Chuck, you'll hit create Linode, choose your image. I'm just going to do Ubuntu 2004, super stable, put the sucker in Dallas, close to me. I'll do a shared CPU with the smallest plan. It's only five bucks a month. And actually, if you're new to Linode and you head on over to linode.com forward slash network, Chuck, you'll get a $100 credit for 60 days. So trying this out will be free for you actually. And after that, five bucks a month, this is why I'm able to run so many virtual machines in the cloud. So once we selected our plan, we'll label it, say NTFY alerts. You can name it, whatever you want. I'll put a password in. And finally, after all that hard work, I'll just click on create Linode and that's it. We now have a virtual machine brewing in the cloud and what like that was like 60 seconds. I think we coffee break while our servers brewing. Okay. My server is done brewing. All I have to do now is grab the SSH access command over here on the right. Should I copy that sucker copy and then launch my terminal Mac windows Linux. It's all the same. Now I'll paste that command in except all fingerprints and to my password and we're in. So we have our cloud server set up, but now what about your house? Well, that can pretty much be anything. As long as it's Linux based for me, I'm just going to use my Kali Linux virtual machine. I'm just going to jump in here, launch my terminal. And from this point, the steps are the same, whether you're in the cloud or at your house or on a Raspberry PI, whatever. First thing we'll do is update our repositories, pseudo APT update, and then we'll install Docker pseudo APT install Docker.io. And we'll do a dash Y at the end. So it doesn't bother us. Ready, set, go. Funny enough, I would like to be notified when that finishes. I wish I had it already. Now at this point, things get kind of easy. All you have to do is run this one command right here. I will have these commands below. So don't worry, just copy and paste. So I'll just paste that command here in my terminal. And if you're a little curious about what's happening, we're using Docker to run a container. This container is right here. Then we are here. Is that German? I don't know how to say that. That's the user and the actual container name. We're telling it to run on port 80 and with a few switches, it's going to run great in the background for us. Once you hit enter the magic happens, ready, set, go. First time pulling it, it's going to go find it, download it. And it, okay. It finished before I could even say anything. That's why I love Docker, but check this out. Let's do one thing. Let's type in Docker actually pseudo Docker PS to see if it's running to make sure it's there. There it is right there. And that is it. Like, so I set this up at the house on my Kali Linux server. Let me go ahead and run it here on my cloud machine as well. Same paste shenanigans. Gosh, I feel like John Hammond saying that cool. So containers running there too. I just set up a server on the cloud and in my house like that. That's what coffee does for you. The server set up like we're done, but now let me show you first, if you did it in the cloud and more specifically through Linode and you want to access it here in Lenovo, we're going to go to our networking tab, looking at our virtual machine. And we're going to scroll down until we see the section on reverse DNS. And just circle that with my pen. We're going to grab this address, just a copy that and just paste that into a new tab. Bam. Here's your NTF Y web interface. You don't have to actually use this. This is just to kind of give you a visual for what is happening. And same thing on prem in your house. It's going to look at my IP address real quick. IP address 10 77 to 40. And if I open up a browser here on my local computer, my same one navigate out there, there's the NTF Y right there. Now, a quick note before we go crazy with this first, the cloud is pretty much done, right? Like it's publicly accessible, meaning anyone can get to it from anywhere, which is probably good for a notification service. If like you do something here in the house, you want to walk away, go get a coffee from some other coffee shop. You can be notified, but the house situation that's not publicly accessible. We're going to have to find a way to make sure our house server can be accessed from anywhere for that. We're going to use cloud flared and I'll walk you through that here in a moment. It'll be fairly quick. I won't go too deep on it. Just know it's the absolute best way to expose your home network to the internet without being too unsafe. It's pretty safe, actually kind of amazingly easy. Now, as far as next steps, let's install the NTF Y app on our phones. That's probably the main way you'll be notified, right? Let's do that. So I'll go to my app store. It should be both on the app store and Google play search for NTF Y. There it is. 55 five-star reviews. Let's change that. Let's make it go crazy. Can we do that? That'd be amazing. I'm gonna go and download this sucker, open it up, allow notifications. Definitely want that for my notification server. Now we need to add our server to the configuration for that. We're going to go to setting and then change our default server. Now notice right here, it's set to NTF Y dot S H. You can actually use that service for free. The creator hosts it, and he also has a paid service if you want some more features. So if you want to show some love and show some support, you can do that, but we don't have to do that. We're self hosting and it's completely free. So I'm going to change that server to whatever my Linode server was. Click on save, save a new server. So we have our server there. Let's go back to notifications. We're clicking the notifications little button. Now what? Now we have to subscribe to what's called a topic. You'll see what that is here in a moment. So all I'll do is click on the plus sign. Now let's make up a name. Let's just say coffee. That's it. Click on subscribe. We're now subscribed to the coffee topic, but how do we get stuff there? What happens? Check this out. This is all it takes. It's so powerful. Oh, I love this. Now NTFY does have a command line interface to send notifications and you can install that. I prefer using curl. So watch this here. My terminal can be any terminal from anywhere. So I'll type in curl, do a dash D and send a message. I'll say, Hey, the coffee is ready. Then I'll paste in my Linode server. And then at the very end, this is how I specify the topic or the category. I'll do a forward slash and type in coffee. That's how I send an alert to the coffee topic, the subscription hit enter. That's it. Now for Android, that probably worked fantastic, right? But on your iPhone, you're like, Chuck, I didn't get a push notification. What's happening? There's one more thing we have to fix. I'll show you that here in a second, but just look at our notifications here. There it is. That's pretty cool. Looking at our web interface, I can subscribe to that same topic. Coffee subscribe, bam. I can see all the notifications there. Now anyone can subscribe to that. That's pretty powerful. And I'm sure the first gut reaction you have is I don't want everyone to subscribe to that. You can do users. You can restrict it. Don't worry now iPhone users. I didn't forget about you. How do we fix the push notifications? Let me show you right now. It's not too crazy. And actually Android users, you want to do this too, because you get more features. So this step is for all users, no matter what you have Android, iPhone, whatever. And just know all we're doing right now is defining a config file because inside this config file, we can do lots of amazing things and you don't want to miss out on features, right? No, you don't. Okay. First, we're going to stop our Docker container. So we'll do Docker PS or pseudo Docker PS. And there's our container ID. I'm just going to copy that and I'll type in Docker container, stop, and then paste that container ID with pseudo once more. Their container stopped Dr. PS to see it's gone. Same deal for the cloud. Now we need to create the configuration file. And for that, we're going to go to get hub first. I got a link below. Here's the config file. We're going to copy all this code by clicking the copy icon top here. Copy. We'll then get back to our terminal and create this file. We're going to type in nano and we'll put it in this location. We'll do forward slash ETC or slash NTF Y forward slash server dot Y ML enter. So we'll paste it all here. And then we'll go to the very top. Now you can scroll all the way up or you can do a shortcut. We'll do control forward slash and type in one for the column. I want to get to, which is the first one. Bam. We're at the top. Now for all users, one thing you want to change, we'll scroll down until we see the base URL right here, right here. You want to change this to the URL of your NTF Y server. Let's change it real quick. First thing I'll do is I'll uncomment this. So I'll backspace, remove that hashtag, the pound sign. And then right after the base URL, I'll add this in HTTP colon forward slash forward slash. Now for my particular server here at my house, it'll be my IP address. 10 dot 70. That's 7.2 40 on Linode. It'll be HTTP colon whack, whack, and my reverse DNS name. Now that's all you have to change. Unless you want to support push notifications on iPhones for that, we'll have to change one thing. So what we'll do here in nano is we'll hit control on our keyboard and W to search. We're going to search for upstream and hit enter there. That's exactly what we want to change right there. We're going to uncomment and move all the space. So just backspace, backspace, backspace, backspace, to where it turns colors or changes colors. And that's all we have to do. Now notice this server, the upstream base URL NTF Y dot S H that's not our server. Why are we doing that? And this will actually fix the push notifications for iOS for iPhone because they do things weird that make it hard to do. Now notice what's happening here. It's saying the upstream base URL is going to be NTF Y dot S H. Now what some of you may think is, okay, are my notifications going to be sent to this other server outside of myself hosting stuff? Are they going to see my things? No, they're not going to see your notifications, but here's what they will see to make sure and facilitate this can happen. All that server will receive is the message ID of the original message. And it will tell the iOS app to pull your server for that message. That's just to get around the weird iOS stuff, but this will enable push notifications. So let's keep going. So with those changes in place, we'll hit control X Y and enter to save now time to run our Docker container. And we have a new command. This one's a bit beefier than our last one. It's enough. Let me go over a few of the highlights of what we're actually doing. Cause we're doing a lot more first notice we have a new switch dash V this is for Docker volumes. We're mapping a folder on our server to a folder inside our Docker container. So notice we're doing the ETC and TFY directory we created. We're also doing cash for persistent cash. And down here at the bottom, we're actually doing an option enabling that configuration. That's the main differences. Let's copy and paste this command. It will be below and run our new containers. I will paste this command hit enter should be good to go. Let's do a Docker PS or pseudo Docker PS. There it is running. I'll do the same thing on my Linode server in the cloud and we're good to go. Now let's test push notifications with Apple. Let's try it out. I'll do a curl dash D. Hey, this should be a bit pushy. I'll specify my Linode server do forward slash copy for the coffee topic. And let's see what happens when you get this ready, right in your face and let's see what happens. Boom. Did you see that? There it is. Push notification went to my watch to check that out. That's what I'm talking about. Now, just in case you're wondering if it works on a local network, let's test it real quick. I'll do curl dash D say, this is all local. I haven't going to the internet and I'll do it to my local IP. I'll do it into a test when I just subscribed to you on my phone and let's see what happens. Boom. Just like that. That's cool. But now for this server that you may set up on-prem in your house, maybe you want to have access to it everywhere you go for that. You're going to use cloudflare tunnels. Now, if you set us up in Linode in the cloud, you don't need this part. Skip ahead to some cool examples right now. I'm going to show you how to set up cloudflare tunnels. Let's do it real quick. Now to set up cloudflare tunnels, you'll need two things. First, a domain name. You can pick this up from cloudflare itself. It's got to buy names like networkchuck.com or the one I created for my videos. Now networkchuck.video. You'll also need a cloudflare account. The cloudflare tunnels feature we're going to be using is completely free and completely awesome. If you don't already have these two things, get these set up before you continue. I do have a more detailed video. We're actually walking through a set up of an account. If you want to see that somewhere over here, but going forward, I'm assuming you have an account and a domain name. Let's get signed in. I'm going to jump into my networkchuck.video domain. And if you've never done this before, you'll see this. On your left side panel, you'll see the access option. Click on that. You'll get a chance to launch Zero Trust and actually start doing this crazy stuff. Go ahead and click on that. You'll probably be walked through setting up a new account. It will be free. Don't worry. Just go through the prompts. I already have mine here. Once you're here at the cloudflare Zero Trust dashboard, you'll click on the access command or menu option once more. Drop that down and then click on tunnels. We're going to create a tunnel to your house, a secure tunnel. And then finally we'll click on, create a tunnel. I'll name it NTFY. Save that sucker for this. I'll be using Docker. I do encourage you to use Docker with me right now. Go ahead and click on that. And automagically it gives us a Docker run command right down here. Here's what we're going to do. We're going to take the command, copy it, go to our on-prem machine, paste that in there. After I do a little pseudo action, it's going to download the cloudflare image or cloud flared image. Actually, uh, it's not running in the background. Let me control C that to stop that nonsense. And I'm going to add a dash ITD right before the cloudflare image name. There we go. So I would do a pseudo Docker PS. It's now running in the background. Okay. Let's get back to cloudflare. I'll scroll down just a bit. There it is. It's up. It's running the tunnel to my house securely. I didn't have to open up any ports in my router or anything. Just it's just Docker from here. We'll click on next. We're not quite done here. We're going to map our subdomain to our server. So I'll say, uh, test and TFY. I'll choose my domain. It'll be never checked out video for service type. I'll do HTTP and the URL will be 10 dot 70 dot seven dot two 40. That's my internal IP address. So cool. It can do this. And that's all I have to do. I'll click on save tunnel. And now let me test this from my cloud machine. I do curl dash D Hey, does this work? And I'll do test and TFY dot network, Chuck dot video. And I'll send it to the test channel. Got it. Check that out. Isn't cloudflare amazing. And of course, if you're going to be out and about, change your server to that new address. Now, let me show you a few fun ways you can use this first. You can actually take the output of any command or whatever you're doing and put that in the notification. So for example, if I'm doing an end map scan here in Kali Linux, I would do this. I would say scan equals. I'm creating a variable here, dollar sign, and then my end map command and map. And then just after that command, I'll do my ampersand. What this will do is it will run the next command. Once this one finishes, which is super powerful. So with my ampersand ampersand, I'll say curl dash D here are the results of the scan. And I'll just call that variable scan, specify my server. I'll send it to the test subscription topic. And it sent all that information to my phone. Check it out. So just imagine if you're like, you're doing a massive in-map scan. It might be a while. I'm gonna go out and do something, hang out with the kids or something. And you might be really curious about what you're running, getting alert, but it'll let you know it's finished. Now, before I continue, just know most commands and things I'm showing you here can be used across the board. Mac Linux windows, keeping in mind that if you do use windows, you'll actually want to use the command prompt with the curl command. Otherwise PowerShell is kind of weird, but looking here in Linux, I want to talk about one thing. Let's say I want to ping a host one on two dot one, six, eight dot zero dot four. And I'll do that three times. Now, if this host was up and I got three successful pings, anything I put after the two ampersands, like a message saying it's up, that would happen. That would work. The ampersand is when a successful command happens, but you can do the opposite. Let's say I wanted it to alert me. If that host was down, not responding, I would change those ampersands into vertical brackets. So check it out. It's going to try and ping it three times. Bam. Did not happen. It sent me a notification. Got it. And I said, it's up. It shouldn't have been up. It should have been, it's down. So if I wrote a ping, a host that I knew was up like one dot one dot one dot one, it shouldn't send me a message. It'll successfully ping and look, it didn't send me anything at all. Now we could actually use the ampersands and their vertical brackets together to do some powerful things. Let's check this out. I can say ping one dot one dot one, three times using ampersands. I can say, Hey, if it works, do this. Then I can add the vertical brackets right after that. If it doesn't work, then do this two separate messages based on what can happen in this command. So here I should get it or it's up alert message. God, it's up, but let me ping something that isn't up like an IP address. I have no idea what it is. And bam, I got a message. It's down or an alert. It's down. So just think about this. You can alert off of anything you do from command line commands like this to scripts, anything within a script. You can do a custom notification. That'll push to your phone. How crazy is that? It's limitless. This is something that would have come in handy so many times in testing my scripts, notifications. What? Oh, it's just so many things, but here's some more ideas to kind of get the juices flowing. What if you are running some updates or upgrades to an old pseudo APT update or upgrade, which can take time, right? I'm just going to do update here for time's sake. And then when that finishes, tell me update finished. So I can do that when I'm installing a pretty big application. Maybe I'm building from source. Maybe I'm using W get to download a big file, set it, tell it to notify me, walk away, make some coffee. How cool is that? But think bigger. What about crontab setting scheduled recurring tasks to run? That's easy enough to do in Linux crontab dash E, but what's annoying is when a job runs, but maybe it fails, or maybe you just want to know that it ran successfully. You can add this to crontab. So let's say you had a script you would run every day. It could be a backup script or something, and you can have it notify you if it succeeds or fail. And that's not just Mac and Linux. You can do windows scheduled tasks too. I'll create a basic task, call it joke of the day, have execute in like a minute or so. I'll say, start a program, point it towards PowerShell and an argument to have it run my script, specifying my script and finish. And bam, got it. Where do young cows eat lunch in the cafeteria? Not too bad. Now that's a silly example, but think of all the things you could trigger in windows, just like you would do in Linux. Now NTFY also has scheduling built in. So check this out. I can send myself a message to the future. So I'll type in curl dash H and in quotes, I'll say in colon, let's say 10 seconds, just like this natural language. And then here's my message. Hey, future me. And of course my server and a roughly 10 seconds, I should receive a message from me. There it is. So that's pretty cool. And you can do more things like 30 minutes next Tuesday and the NTFY server will take care of that. That's pretty powerful. Now, one thing I love about this is again, you can use it with any kind of command or scripts. And one thing I'm always doing is rebooting stuff, rebooting a server. And I want to know, Hey, when does it come back up? So I can come back in here and do some more work. NTFY makes it super easy to keep myself up to date. Check this out with this command. We're gonna do a ping, a simple ping paste it here real quick. And there's a lot going on, but at its core, all I'm doing is pinging this host and I'm in a loop. So it's saying, while with that exclamation Mark, I'm saying, and while there's nothing, while I'm not receiving anything back, keep pinging it, do it one time and then sleep. So this is saying, Hey, while the server's down, just keep doing this thing. Keep doing it, keep doing it. But when it comes back up, boom, give me a message. Now I don't know why I have it's down. Let me do something a bit happier. It's up. And you know what? We can actually add emojis. I didn't show you how to do this. We can do a dash H and do TA to that. Now there's a full list of what emojis you can use and how you can use them on the NTFY documentation. But this is going to be a nice little fun one. Okay. So I'm gonna run this command. And right now this host is down because it's my windows host and I have my firewall on in the private network. Let me turn it off. Bam. What I should see here is it'll stop its loop. Yep. It's done. And then I should get a notification. Oh yeah. Emoji and everything it's up. And of course I can do the opposite by omitting the exclamation point. I don't want to see if a server goes down. That's always helpful for me though. When I'm rebooting stuff, reboot, run that command, get a notification when it comes back up. But many of you are probably thinking, Chuck, that's what monitoring programs are for like uptime Kuma. Yeah. And you know what? You can use uptime Kuma with NTFY. Let me show you on anything we monitor in uptime Kuma, we can set up notifications on the right here and choose my system. I want to have notified right here. NTFY is built in specify the topic, the server, username and password are optional, but just know NTFY has integrations with a bunch of stuff. And if it doesn't have an integration, it can be used as a simple web hook. You can use it with pretty much anything. So think Ansible, salt, puppet, chef, get hub actions, anything in the cloud. And then one last fun thing I want to show you, let's say you get your laptop up, right? And you're busy, you're working, you're on battery and you want to make sure you plug in, or at least you have enough power to do something else. You can set an alert for your battery life. When it gets to a certain percentage, you can have NTFY alert you check this out. So here I have a PowerShell script that'll check my battery status. And I can say at any percentage that goes below this alert me, send me an NTFY message. How cool is that? Check it out right now. It's a 64%. I'm going to change it to 63, save this script. Let's say, you know, I'm, I'm, I'm busy. I want to walk away and maybe do something, or I'm, I'm like super focused. This will let me know, or I can even just add this to a scheduled task to check every once in a while. So I don't have to sit here and run it. Okay. Bam. Just got it. Battery's low. How cool is that? Same thing can be done on Mac and Linux. I'll have a script below. They can do stuff like CPU, GPU, get notifications. It's so powerful. Your imagination is the only limit. So at this point, that's really all I want to show you. I could show you a lot more. Yeah. But I want to let you figure it out. Go to NTFY.sh. They have a ton of documentation. Like you can see here, have a bunch of fun examples. They have like, for example, how you can control access, creating users and roles, creating ACLs, access tokens. This is well thought out, very well done. And shout out to Philip, the creator. He actually reached out to me as a, Hey, I've got this pretty cool tool. I'm like, whoa, hold on. This is actually pretty cool. I've got to make a video about this and just know it is free. It is open source. You can host everything yourself. It's amazing, but you can also pay for his service as well that he hosts NTFY.sh. So if you don't want to host anything and you want to do his stuff, check it out. And also I would love to see the other ways you might use NTFY. So please comment below. Like I said, the options are endless and I want to see what you guys come up with. That's all I got. I'll catch you guys next time.