I set up a fresh server, opened it to the entire internet, and left it running for 24 hours to see what would happen to it. By the end of this video, you'll understand exactly what bots try on every new server and why, so you can make sure yours doesn't have what they're looking for, just by watching me walk through what attacked my server. First, let's look at the setup. We're running Ubuntu 24.04 LTS server on AWS. We opened its security group to all inbound traffic, which means every port is reachable, and we left UFW turned off, which is the default on Ubuntu. It runs two things: SSH on port 22 with key login only, and Nginx on port 80 serving the default welcome page. There's nothing on it worth stealing, and we didn't share its IP with anyone. About an hour in, we also pointed a brand new domain at it, got a free HTTPS certificate, and told Nginx to log which domain each request asks for. The first failed login showed up just 74 seconds after the server booted. To see it, we run sudo journalctl -u ssh, which shows the logs for the SSH service. We get lines like, 'Invalid user admin' from an IP address we've never seen. Invalid user means someone tried to log in with a username that doesn't exist on this server. Each of these is a bot running through a list of common usernames and passwords, hoping one of them works. That's called a brute force attack. Our server doesn't accept passwords at all, but the bots don't know that until they try, so they try anyway. To see how many there were, pipe that into grep -c followed by 'Invalid user' in quotes. The -c counts the matching lines instead of printing them. After 24 hours, we get 6,212. Next, let's see which usernames they tried. Run the same command, but instead of counting, pipe it into awk '{print $8}' to grab just the username, then sort, uniq -c, and sort -rn. Unique -c counts how many times each name shows up, and sort -rn puts the biggest numbers on top. Near the top, we see admin, user, test, support, and postgres. Those are bots trying to break into default accounts from routers, test machines, and database installs that people forgot to lock down. But right next to admin, we see sol and solana. And if you add those two together, they beat admin. Those are accounts people create to run Solana crypto nodes. So those bots aren't looking for just any server. They're looking for one with a crypto wallet on it. You won't see root in this list because root exists on every Linux server, so those attempts get logged differently. The same goes for Ubuntu, the default user on AWS. Grep for 'authenticating user root' instead, and we get another 3,041. That makes root the most tried username by far. Add it all up, and that's over 9,000 attempts in one day, or about one every 9 seconds on a server I didn't tell anyone about. So where are all these attempts coming from? To count the different IPs, use awk '{print $10}' instead, since that's where the IP sits in each line, then sort -u and wc -l. We get 127 different IP addresses, and that's just the ones that tried fake usernames. Let's look one of them up. We install whois with sudo apt install whois, then run it followed by the IP. We use it to show who owns an IP address, and in this case, it's a cloud hosting company, just like AWS. Most of the others look the same. They're rented servers or machines that were hacked earlier and now attack for someone else. Most of them also hit us for a few minutes, try a long list of usernames, and never came back. So banning IPs one at a time or blocking a whole country barely helps. The next attack comes from a different IP. So SSH got hit hard, but it's only one port, and the bots were knocking on the others too. To see that, we need to watch traffic going to ports where nothing is running. Run sudo tcpdump -n -i ens5 followed by 'not port 22 and not port 80 and not port 443'. That filters out SSH and our web server, so we mostly see packets going to ports we never opened. You'll also see a bit of the server's own traffic, like DNS lookups. The -n keeps IPs and ports as numbers, and ens5 is this server's network interface, which you can find with ip a. Within a minute, packets start arriving, and most of them show flags, then S in square brackets. That's a SYN, the first step of every TCP connection. The ports tell you what each bot is hoping to find. Port 23 is Telnet, which cheap cameras and routers still run with default passwords. That's how the Mirai botnet grew to hundreds of thousands of devices. Port 3389 is Windows Remote Desktop, and port 6379 is Redis, a database that often runs with no password at all. And port 2375 is the plain HTTP Docker API. If you expose it, anyone on the internet can start containers on your server, and what they usually start is a crypto miner. Now look at what our server sends back. Every SYN gets an R. in return, which is a reset. A reset means nothing is listening on that port, but it also tells the scanner this IP is alive, so it's worth coming back to. If UFW were on with default deny, those packets would get dropped silently, and the scanner would get nothing back, which is what should be happening. Not every scanner is hostile, though. Some of those packets come from companies like Shodan and Censys. They scan the whole internet every day and publish what's running on each IP. That means your open ports end up in a search engine, and attackers search it too. So in the first hour, bots found our IP just by scanning every address on the internet. But the strangest request in our logs didn't come from scanning. It asked for our new domain by name, 12 seconds after we got the certificate, and we hadn't shared that domain with anyone. Now, if you're serious about gaining skills with Linux, Docker, Kubernetes, and more, start the full DevOps path, beginning with the Linux course for free at stackmonsters.com. You run real commands in labs right in your browser. You get instant feedback and nothing you break is real. Just scan the QR code or click the link in the description. So back to how bots find out about new websites almost instantly. When we set up HTTPS, we got a certificate from Let's Encrypt. Every certificate a public authority issues gets written to public certificate transparency logs, so anyone can catch a certificate that was issued by mistake. You can search those logs yourself on a site called crt.sh. Type in your domain, and you'll see every certificate ever issued for it. Bots watch those logs live. When a new certificate appears, they know a new website just went up, and they visit it right away. That's dangerous for half-finished setups. For example, if you install WordPress and haven't finished the setup page, whoever reaches that page first gets to create the admin account. So never leave an install page public, even for a few minutes. To see what the bots asked for, run sudo tail -f /var/log/nginx/access.log. Tail -f keeps printing new lines as they arrive. Each line shows the IP, the time, the request, the status code, and the user agent, which is the name the client gives itself. The first request we see is for /.env. A .env file is where a lot of apps keep their secrets, like database passwords and AWS keys. If your web server serves that file by mistake, bots can have your cloud keys within minutes, and the usual result is a huge bill from crypto miners. Next is /.git/config. If you deploy by cloning your repo into the folder Nginx serves, that file tells the bot your whole git history is downloadable, including any password you ever committed. Then come requests for wp-login.php and phpmyadmin, even though this server has never run PHP. The bots don't check what you run first. It's cheaper for them to try every path on every server. Some requests try to run commands on the server directly. One has the shell command cd /tmp, then wget, then a download link right inside the URL. It targets a bug in old routers and camera recorders. If it worked, the device would download malware and join a botnet. Another has a user agent that starts with dollar sign, curly brace, JNDI. That's Log4Shell, a bug in a Java logging library from 2021, where just writing that text to a log was enough to take over an unpatched server. Our server doesn't run Java, but the bots send it anyway because unpatched servers are still out there. So did any of this actually work? Let's check the web first. In the access log, the status code is the ninth field, so run sudo awk followed by '$9 == 200' in single quotes, then /var/log/nginx/access.log*. The star matters. Ubuntu rotates Nginx logs every day, so part of our 24 hours already moved into access.log.1. That prints only the requests that succeeded. Everything else got an error, like 404, not found, or a redirect to the HTTPS version of the site. The attacks that hit / just got the welcome page. Now SSH. Run sudo journalctl -u ssh again and grep for 'Accepted'. That shows every login that succeeded, and every one of them is our own key from our own IP. So after 24 hours, over 9,000 attempts and well over 127 IP addresses, nobody got in. But that's only because this server uses keys and runs almost nothing. With a weak password, a server like this usually gets taken over within a few hours. So on a real server, the security group should only open the ports you need, which here are 22, 80, and 443. That alone makes scans to every other port get no answer at all, because the security group drops them before they reach the server. Then turn on UFW with default deny as a second layer. So if a port ever gets opened by mistake, the server still drops those scans itself. Just allow SSH in UFW before you turn it on, or you'll lock yourself out of your own server. Keep SSH on keys only and add fail2ban. It bans each IP automatically after a few failed attempts, so you don't have to chase them one at a time. Never expose Redis, a database, or the Docker API to the internet. Keep them on localhost or on a private network. And if you run them in Docker, publish their ports on localhost too, because ports that Docker publishes skip UFW completely. Keep .env and .git out of the folder your web server serves, and leave automatic security updates on. Ubuntu enables them by default, and almost every exploit we saw targets a bug that was fixed years ago. If you want the full step-by-step of how to set up security on your Linux server, check out our server security video. And now you know the attacks that bots try on every Linux server every day. And here's a quick cheat sheet for checking bot activity on your server. Check SSH attempts with journalctl -u ssh, count them with grep, awk, sort, and uniq, lookup IPs with whois, watch port scans with tcpdump, and read web attacks in the Nginx access log. And remember, every port you open gets tested within the hour, so only open what you're ready to defend. And if you want a hands-on way to learn the DevOps skills tech jobs ask for, stackmonsters.com gives you hands-on labs for Linux, Docker, Kubernetes, and much more, right in your browser, and it's free to get started. Thanks for watching, subscribe for more, and I'll see you in the next one.