MODULE 4.2 / 8 OF 8

VPS from scratch and 24/7 operation

Prepare a deployment plan, monitoring, backup and service verification.

0% 0 of 0
01 / OSWORKA VPS is a machine under yourresponsibility02 / OSWORKEnter via SSH and preserveaccess03 / OSWORKInstall only what is necessary04 / OSWORKProtect the network andcredentials05 / OSWORKSystemd supervises the process06 / OSWORKAvailability requires a careroutine
The six pieces of this module. At the end, you produce a learning evidence.
6 topics
~60 min reading and practice
1 verifiable delivery
Guided training lab

1A VPS is a machine under your responsibility

What it is

A VPS is a rented virtual server: a remote computer with memory, disk, and network. You manage users, updates, and processes. Start with a small machine compatible with the application; do not rent a GPU just to call a model via API. The remote model runs on the provider’s infrastructure.

Why learn

A powered‑on machine does not mean a healthy service. VPS, storage, and API costs are separate. Before hiring, define what needs to run continuously and who will monitor incidents.

Key concepts

Remote server; resources; recurring cost; operational responsibility.

In practice

A small bot that queries fictitious data does not need the same infrastructure as a local model. The manager estimates load, budget, and availability before choosing the plan.

✓ Do it

Fill out materiais/plano-vps.md. Record operating system, access method, monthly limit, responsible person, and how to shut down the resource.

✗ Avoid

Accepting a conclusion without checking the input that supports it.

2Enter via SSH and preserve access

What it is

SSH creates a protected connection to manage the machine. Use the registered public key as per the provider and verify the server's identity. Create a work user with administrative permissions when needed. Keep the original session open while testing a second connection.

Why learn

Changing the firewall or authentication without testing a recovery route can lock you out. The provider's console is the fallback when the normal connection fails; verify that it works before restricting the network.

Key concepts

Public key; fingerprint; user; sudo; recovery.

In practice

The command ssh usuario@ip-da-vps opens the session. usuario and ip-da-vps are placeholders to replace, not real values. The prompt name and pwd help confirm which machine you are on.

3Install only what is necessary

What it is

The lab examples use Ubuntu with apt. Update the package list and review the proposed upgrade. The base bot requires Python 3; Git helps transfer the project. Node, Docker, and Codex are optional depending on the application, not a mandatory list for any VPS.

Why learn

Each dependency adds maintenance. A simple service with few components is easier to explain, update, and recover. Installing tools out of habit creates work without increasing the needed capacity.

Key concepts

apt update; apt upgrade; dependency; virtual environment when needed.

In practice

Reference sequence: sudo apt update, sudo apt upgrade, sudo apt install git python3. The kit bot uses only the standard library, without installing external Python packages.

Sequence to try

  1. Prepare a training copy.
  2. Before confirming the upgrade, read the involved packages. Check python3 --version and git --version, then create ~/projetos in the work account.
  3. Record the observed result and the next correction.

4Protect the network and credentials

What it is

The firewall filters network connections. For long polling, the bot needs to go out to HTTPS; it does not need to expose a bot port to the internet. Before enabling UFW, open the actually used SSH port and check local and provider rules. Restrict the .env with chmod 600 and keep it out of Git.

Why learn

Opening all ports to “make it work” increases risk without diagnosing the cause. If the process does not respond, outbound network, token, and execution each deserve separate checks.

Key concepts

Input and output; SSH port; firewall rule; file permissions.

In practice

If SSH uses port 22, sudo ufw allow 22/tcp may be appropriate. If it uses another port, the rule needs to change. Only run sudo ufw enable after testing the configuration and recovery access.

✓ Do it

List ports actually needed in the plan. Record which commands vary by provider and never treat the port example as universal.

✗ Avoid

Mix the training copy with private files or production work.

5Systemd supervises the process

What it is

systemd is the service manager for many Linux distributions. A unit describes which program to start, with which user and in which directory. Restart=on-failure restarts after a failure, but does not fix a persistent error. The kit provides a parametrized unit for the oswork user.

Why learn

Running the bot in an SSH session may terminate the job when the connection closes. Supervision allows it to restart with the machine and centralize logs. It does not replace alerts, limits, or root‑cause analysis.

Key concepts

Unit; service user; directory; restart; journal.

In practice

After adapting the paths, use sudo systemctl daemon-reload and sudo systemctl enable --now oswork-bot. Check systemctl status and journalctl -u oswork-bot -n 50 --no-pager.

6Availability requires a care routine

What it is

Continuous operation combines supervision, updating, monitoring, backups, and tested restoration. Make copies of data outside the machine, protect credentials, and set retention. A backup is only validated when you restore a copy and verify its contents.

Why learn

Without monitoring, a service can stay down for days. Without restoration testing, the copy may be incomplete. The real promise is a recoverable routine, not an infallible machine.

Key concepts

External check; logs; backup off the VPS; restoration; spending limit.

In practice

A daily check logs the bot's response and disk space. A monthly test restores vendas.csv in a separate folder and compares the total. Credentials remain private, not included in the public backup.

Criteria to review your delivery

Use this rubric after the lab. Each line asks for evidence; checking reading does not mean the practice was performed.

Criterion Expected evidence If not passed
Scope The delivery matches the objective of this class. Reduce the task and name a single result.
Inputs You know which files or data were used. List the sources and remove unrelated material.
Execution The procedure was carried out in the training environment. Differentiate what was planned from what was done.
Verification A result was compared with a reference. Open the file or repeat the verifiable query.
Secrets No token, password, or private data was shared. Review the work copy before any submission.
Continuity Another person can find the next step. Update README and record a concrete pending item.

GET HANDS-ON / ~15 MIN OR IN STEPS

From the local folder to a supervised service

Use fictional files and a training folder. Practices involving installation, Telegram or VPS may require additional time for registration and configuration.

Ubuntu VPS · adapt paths first

Read the block before using. Fields like Your Name and usuario@ip-da-vps are examples to adapt; administrative commands belong only to your training environment.

sudo apt update
sudo apt upgrade
sudo apt install git python3
# Adapt the kit unit to the actual user and path.
sudo systemctl daemon-reload
sudo systemctl enable --now oswork-bot
systemctl status oswork-bot --no-pager
journalctl -u oswork-bot -n 50 --no-pager

Ready criterion

Prepare a deployment plan, supervision, backup and service verification. Record the generated file, the executed test and the observed result.

Open lab files and models

Check what remained

Does installing Codex on a VPS guarantee an active 24‑hour agent?

View commented answer

No. You need a service or scheduler, a supervised process, valid credentials, network and monitoring.

If your answer was different, return to the corresponding topic and write the difference in one sentence. The check does not block your study.

Module summary

  • Remote server; resources; recurring cost; operational responsibility.
  • Public key; fingerprint; user; sudo; recovery.
  • apt update; apt upgrade; dependency; virtual environment when needed.
  • Input and output; SSH port; firewall rule; file permissions.
  • Unit; service user; directory; restart; journal.
  • External check; logs; backup off the VPS; restoration; spending limit.

Consult the source

Tools verified on 20/09/2026; screen names and availability may change.

Full module