You Need To Know These Network Services in Linux !!

Hello there! Grab a coffee (I’ve got a strong black one going myself, no sugar, because we’ve got work to do) and let’s settle in. If you followed our last session on Task Scheduling, you’ve already figured out how to make Linux do the boring stuff for you. You’ve got your cron jobs cleaning up folders and your systemd timers ticking away like clockwork.

But here is the thing: a hacker working only on their own local machine is like a driver with a Ferrari who never leaves their own driveway. It’s a bit pointless, isn’t it? To truly do some damage—or, you know, ethical exploration—you need to talk to other machines. You need to move files, control remote shells, and hide your tracks.

Today, we’re diving into Network Services. We’ll look at SSH (our bread and butter), how to spin up a “quick and dirty” Python server for file delivery, and how to get your VPN sorted so you can actually access those juicy HackTheBox labs. Ab game shuru karte hain (Now the game really begins), let’s get into the nitty-gritty of how these services actually work.




The “Front Doors” of Linux: What are Network Services?

Imagine a Linux server is like a massive apartment block. Each “service” is a specific flat with a specific purpose. One flat handles mail, another handles visitors, and another might be a storage unit. As hackers, we are interested in which doors are open, who is living there, and if they’ve left a spare key under the mat.

In technical terms, a network service is an application that runs in the background (a daemon) and listens for incoming connections on a specific port. Without these services, the internet would just be a bunch of lonely computers talking to themselves.

1. SSH: The King of Remote Access

If there is one service you absolutely must master, it’s SSH (Secure Shell). In the old, dark days of the internet, people used Telnet. Telnet sent everything—including passwords—in plain text. If you were “sniffing” the network, you could see everything. It was a proper disaster.

SSH fixed that by encrypting the connection. For a hacker, SSH is beautiful. It’s how we maintain persistence, how we tunnel traffic, and how we manage our remote “Command and Control” (C2) servers.

Are You Ready to Connect? (Installation)

Most Linux distros come with the SSH client, but the server isn’t always installed or enabled. You need the client to “go” somewhere and the server to “receive” visitors.

Let’s check if we have them. If not, we’ll grab them from the repositories.

# First, let's update our package list (always a good habit)
sudo apt update

# Install the client (to connect TO other machines)
sudo apt install openssh-client -y

# Install the server (to allow others to connect TO you)
sudo apt install openssh-server -y

Checking the Pulse: Is the Service Running?

Remember from our last article how we used systemctl to manage tasks? We use the same tool here. Even if the software is installed, the “door” might be locked.

# Check if the SSH daemon (sshd) is breathing
systemctl status ssh

If it says inactive (dead), don’t panic. We just need to kick-start it:

# Start the service
sudo systemctl start ssh

# Make sure it starts automatically when you reboot
sudo systemctl enable ssh

Making the Connection

To connect to a remote machine, the syntax is straightforward: ssh username@ip-address.

But wait, what if the target is running SSH on a weird port to try and hide from us? (Spoiler: It doesn’t work, we have port scanners, but people try it anyway).

# Connecting to a default port (22)
ssh cry0l1t3@192.168.1.50

# Connecting to a custom port using the -p flag
ssh cry0l1t3@192.168.1.50 -p 2222

# Using a specific identity file (SSH Key) instead of a password
# This is much more secure and very common in the real world
ssh -i ~/my_secret_key.pem admin@10.10.10.150

(Aside: If you’re ever on a Red Team engagement and you find an SSH private key lying around in a .ssh folder, that is a massive win. It’s basically the master key to the flat.)

2. The “Quick and Dirty” Python HTTP Server

Sometimes, you don’t need a full-blown Apache or Nginx web server (which, by the way, we’ll be chatting about in the next article!). Sometimes, you just need to get a script from your machine onto a target machine right now.

Maybe you’ve found a vulnerability on a target, and you need to upload a privilege escalation script like LinPeas. You don’t want to spend twenty minutes configuring a web server. You want a “Temporary Python Server.”

Spinning Up the Server

Python has a built-in module that turns any directory into a clickable web page. It’s honestly one of the handiest tools in a hacker’s toolkit.

First, make sure you have Python installed:

sudo apt install python3 -y

Now, navigate to the folder where your “loot” or “tools” are kept and run this:

# Start a basic server on the default port 8000
python3 -m http.server

That’s it! If your IP is 192.168.1.20, anyone on your network can now go to http://192.168.1.20:8000 in their browser and download your files.

Advanced Variations: Custom Ports and Directories

What if port 8000 is blocked by a firewall? Or what if you’re feeling a bit lazy and don’t want to cd into the directory first?

# Run the server on port 80 (the standard web port)
# Note: You need 'sudo' for ports below 1024
sudo python3 -m http.server 80

# Specify a directory without moving there
python3 -m http.server 8888 --directory /home/cry0l1t3/target_files

Metaphor Alert: Think of this Python server like a pop-up lemonade stand. It’s not meant to be there forever, it’s not very secure, but it’s perfect for a quick transaction before you pack up and disappear. Scene sorted hai (The scene is sorted), as they say.

3. VPN: The Secret Tunnel to the Lab

When you’re practicing your skills on platforms like HackTheBox (HTB) or TryHackMe, you aren’t attacking targets on the open internet (that would get you a visit from the police, which is a bit of a buzzkill). Instead, you’re attacking machines inside their private, isolated network.

To get inside that network, you need a VPN (Virtual Private Network).

Installing the Client

For most hacking labs, OpenVPN is the standard. It creates an encrypted tunnel between your machine and the lab’s network.

# Install the OpenVPN client
sudo apt install openvpn -y

Connecting to HackTheBox

Once you download your .ovpn configuration file from the HTB website, connecting is a one-command affair.

# Navigate to where you downloaded the file
cd ~/Downloads

# Fire up the tunnel
sudo openvpn starting_point_cry0l1t3.ovpn

You’ll see a wall of text (don’t blink, it looks cool), and eventually, it’ll say Initialization Sequence Completed. Congratulations, you are now “on the inside.” Your machine now has a new network interface, usually called tun0, with a special IP address that can talk to the lab machines.

You can watch the video for better understanding the openvpn connection to the HackTheBox VPN.

Why Should a Hacker Care? (The Bigger Picture)

You might be thinking, “This is just basic networking, where’s the hacking?”

Well, think back to our Task Scheduling article. Imagine you’ve compromised a machine. You could set a Cron Job that runs every hour, checks if your SSH connection is still active, and if not, starts a Python Server to exfiltrate any new files found in the /home/user/Documents folder.

See how it’s all coming together? Automation (Task Scheduling) + Connectivity (Network Services) = A very efficient hacker.

In our next session, we’re going to take this a step further with Web Servers. We’ll look at Apache, how to host multiple sites on one server, and how to use tools like curl and wget to poke and prod at headers like a pro. It’s going to be a proper deep dive, so make sure you’ve topped up your coffee beans by then.

Frequently Asked Questions (FAQs)

1. Is it safe to leave SSH running on my machine?

Generally, yes, if you use strong passwords or, better yet, SSH keys. However, if you’re not using it, it’s a good practice to stop the service (sudo systemctl stop ssh). Hackers (the mean kind) love to brute-force SSH logins.

2. Can I use the Python HTTP server to receive files?

Actually, no. The standard python3 -m http.server is for GET requests only (downloading). If you want to upload files from a target back to your machine, you’d need a more complex script or a different service like scp (Secure Copy, which runs over SSH!).

3. Why does my VPN keep disconnecting?

Usually, this is down to network instability or a timeout. If you’re on HackTheBox, make sure you’re using the “UDP” protocol if “TCP” is slow, or try a different server location. Also, ensure you’re running it with sudo, as it needs to modify your system’s routing table.

4. How do I know which ports are open on my own machine?

You can use a command like ss -antp or netstat -tunlp. This will show you every service currently “listening” for a connection. It’s like doing a quick security check on your own front doors.

5. What’s the difference between openssh-server and openssh-client?

The client is the tool you use to “call” someone else. The server is the “telephone” sitting on your desk waiting for someone to call you. Most hackers need both.

I hope that clears things up! Go ahead and try setting up an SSH connection between two VMs, or host a folder using Python and try to access it from your phone’s browser. It’s the best way to learn.

Until next time, keep your coffee hot and your shells persistent. Cheers!

Leave a Reply