how did I NOT know about this?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Command line, push notifications. This is crazy. Check this out. It's so powerful. Let's say I'm running an Nmap 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 N T F Y 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'll take about five minutes and here's what we're doing. We'll set up an N T F Y 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 N T F Y 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 G P T. Why did the push notification go to school? Because it wanted to be a little more alert, actually, wasn't that bad. Alright, 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 it 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, od, which is now owned by Akamai, making them more powerful. Now OD 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. Lemme show you once you get signed up. When you go to anode.com/network, Chuck, you'll hit create you anode. Choose your image. I'm just going to do Ubuntu 2 0 4 super stable. Put the sucker in Dallas, close to me. I'll do a shared C P U with the smallest plan. It's only five bucks a month. And actually if you're new to Leno and you head on over to leno.com/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 N T F Y 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 le node and that's it. We now have a virtual machine brewing in the cloud. And what that was like 60 seconds I think with coffee break while our server's brewing. Okay, my server is done brewing. All I have to do now is grab the S S H access command over here on the right. So you want to copy of 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. Enter my password and red. 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 Cali 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 a p t update, And then we'll install Docker, pseudo a p t, 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 weeder 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 PSS to see if it's running to make sure it's there. There it is right there. And that is it. So I set this up at the house on my call Linux server. Lemme 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 servers set up we're done. But now what? Let me show you first. If you did it in the cloud and more specifically through LE Node and you want to access it here in LE node, 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 d n s. Lemme just circle that with my pen. We're going to grab this address, just copy that and just paste that into a new tab. Bam. Here's your N T F 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 up my IP address real quick. IP address, 10 77 2 40. And if I open up a browser here on my local computer, my same one navigate out there, there's the N T F Y right there. Now, a quick note before we go crazy with this first, the cloud is pretty much done right? It's publicly accessible, meaning anyone can get to it from anywhere, which is probably good for a notification service. If 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 too unsafe. It's pretty safe, actually. Kind of amazingly easy. Now, as far as next steps, let's install the N T F 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 N T F Y. There it is, 55 5 star reviews. Let's change that. Let's make it go crazy. Can we do that? That'd be amazing. I'm going to 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 N T F Y Sh. You could 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 and it's completely free. So I'm going to change that server to whatever my LA node server was. Click on save a new server. So we have our server there. Let's go back to notifications. So we click in 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 and I'll just 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, N T F Y does have a command line interface to send notifications and you can install that. I prefer using curl, so watch this here in my terminal. It 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 low notes server, and then at the variant 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? Lemme 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 there. Container stopped. Docker 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 GitHub. First, I got a link below. Here's the config file. We're going to copy all this code by clicking the copy icon at the 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 slash et c slash N t Y slash server yml 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 slash and type in one for the column we 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 R l right here, right here. You want to change this to the U R L of your N T F Y server. Let's change it real quick. First thing I'll do is I'll uncommon this. So I'll backspace remove that hashtag the pound sign, and then right after the base, U R l, I'll add this in http slash schwart slash. Now for my particular server here at my house, it'll be my IP address, 10 point 77.2 40. On LE node, it'll be http colon, wack wack, and my reverse D N Ss 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 CTR 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 uncon 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, U R L N T F Y sh. 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. They make it hard to do. Now, notice what's happening here. It's saying the upstream base U R L is going to be NT ffy sh. Now, what some of you may think is, okay, are my notifications going to be sent to this other server outside of my self 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 an awful. Let me go over a few of the highlights of what we're actually doing because 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 E T C N T F Y directory we created. We're also doing cache for persistent cache, 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'll 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 LE node 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 lin node server. Do four slash coffee for the coffee topic and let's see what happens. We can 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 too. 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, not even 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 this up in anode 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 could pick this up from CloudFlare itself. Just got to buy name, so like network check.com or the one I created for my videos. Now, network check.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. Where're actually walk you through a setup 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 network chuck.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 and click on that. You'll probably be walked through setting up a new account. It'll 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 it'll click on create a tunnel. I'll name it N T F Y. 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 that 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, it's not running in the background. Lemme control C that to stop that nonsense. And I'm going to add a dash i t d right before the CloudFlare image name. There we go. So I'll do a pseudo docker pss. 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. It's the tunnel to my house securely. I didn't have to open up any ports on my router or anything. 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 test and T F Y. I'll choose my domain, which will be network chucked up video for service type. I'll do H T T P, and the U R L will be 10 point 70, 0.7 0.2 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? Now I'll do test N T Y network Chuck video, and I'll send it to the test channel. Got it. Check that out. Isn't cloud flared amazing? And of course, if you want 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 Nmap scan here in Cali Linux, I would do this. I would see a scan equals I'm creating a variable here, dollar sign, and then my Nmap 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 inmap scan, it might be a while. I'll go out and do something, hang out with the kids or something, and you might be really curious about what you're running. Get an alert. It'll let you know what's finished. Now, before I continue, just know most of the 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 1 9 2 0.16, 8.04, 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 pinging 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 1.1 0.1 0.1, 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 ampersand and their vertical brackets together to do some powerful things. Let's check this out. I can say pinging 1.1 0.13 times using ampersand. 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. Got it, it's up. But let me pinging something that isn't up like an IP address. I have no idea what it's, and bam, I got a message. It's down or an alert, it's down. So just think about this. It 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've come in handy. So many times in testing my scripts, notifications, I ask you 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 doing a little pseudo a p t 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 Git 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 crt? TAP setting scheduled recurring tasks to run. That's easy enough to do in Linux CR tab dash E. But what's annoying is when a job runs, but maybe it fails or maybe you want to know that it ran successfully, you can add this Toron tab. 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 task 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, add an argument to have it run my script, specifying my script and finish and bam, got it. Where do young cows eat lunch and 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, N T F Y 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 N 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 in 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 N T F Y 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 script. 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? N T F Y makes it super easy to keep myself up to date. Check this out. With this command, we're going to do a ping, a simple pinging, I'm just going to 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, 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 this 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. I'm going to 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 ta. Now there's a full list of what emojis you can use and how you can use them on the N T F Y documentation, but this is going to be a nice little fun one. Okay, so I'm going to 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. Lemme 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 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're probably thinking, Chuck, that's what monitoring programs are for, like uptime kuma. Yeah, and you know what? You can use Uptime Kuma with N T F Y. Lemme 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. N T F Y is built in. Specify the topic. The server username and password are optional, but just know N T F Y 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, GitHub, actions, anything in the cloud. And then one last fun thing I wanted to show you. Let's say you get your laptop up 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 N T F Y 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 N T F Y message. How cool is that? Check it out. Right now it's at 64%. I'm going to change it to 63. Save this script. Let's say I'm busy, I want to walk away, maybe do something or I'm super focused. This will let me know. Or I could 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 C P U G P U, 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 NT y sh. They have a ton of documentation like you can see here. They have a bunch of fun examples. They have. 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 and said, Hey, I've got this pretty cool tool. And I'm like, eh, 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 t y 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 N T F Y. 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.
Info
Channel: NetworkChuck
Views: 897,922
Rating: undefined out of 5
Keywords: Nfty, curl, docker, linux, cloudflare, windows, mac, open source, server, cloud, push notifications, on prem, linode
Id: poDIT2ruQ9M
Channel Id: undefined
Length: 23min 6sec (1386 seconds)
Published: Wed Aug 30 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.