How to create an Ubuntu VPS for a Python script
Create a small Ubuntu server on DigitalOcean, connect from your computer with an SSH key, and know what you are paying for and how to stop the charges.
In this guide
You need a computer that can stay online when your laptop is off. A VPS is a small computer you rent over the internet. Here, you’ll create one with Ubuntu, connect to it from your own computer, and check that you have the access needed to install a Python script.
We’ll use a DigitalOcean Droplet—its name for a VPS—with Ubuntu 24.04 LTS, 1 GiB of memory and a $6 monthly base price. It’s a concrete starting point for a small website checker or scheduled report, not a promise that every Python program will fit. You don’t need a domain or a finished script yet.
Already have an Ubuntu 24.04 server and a working administrator login? Keep it. Continue with running a script continuously or running it on a schedule. If you’re unsure whether you need a VPS, first check whether your existing hosting fits.
Before you create anything: cost and access
You’ll need a Windows 11, macOS or Ubuntu 24.04 computer, access to your email, and a payment method accepted by DigitalOcean. Ubuntu is the Linux desktop covered here. You’ll create a login key on your computer before renting the server, so you can check that the connection tools work without incurring charges.
The Basic Regular, 1 GiB, 1 vCPU, 25 GiB SSD bundled plan was listed at $6/month on September 23, 2026. Memory holds the running program; disk space holds its files. A shared CPU means processing capacity is shared with other customers. This starting size is for light tasks, not large datasets, AI models or browser automation. Check the current plan price before ordering.
The price is a cap for this server’s base usage, not a cap on your whole account. Taxes, optional services and traffic above the included allowance can add to it. DigitalOcean bills this bundled plan per second, with a minimum charge of 60 seconds or $0.01, whichever is higher. Billing starts when you create the server and continues even if you switch it off. Deleting the Droplet stops its future server charges; closing your terminal does not. The billing rules explain the details.
Deleting the server permanently removes its files. We’ll leave paid extras off for this first setup, including backups, so keep your original script and important files on your own computer.
1. Make your login key on your computer
Open PowerShell from the Windows Start menu, Terminal on macOS, or your Linux terminal. This is a window where you type commands. Paste one block at a time and press Enter; don’t type the surrounding page text.
Check that SSH is available. SSH is the tool that opens an encrypted terminal connection to your server:
ssh -V
You should see a version beginning with OpenSSH. If Windows says the command isn’t recognized, open Optional features from Start search, select View features or Add a feature, find OpenSSH Client and install it. Reopen PowerShell and run the check again. You need the Client, not the Server. Microsoft’s OpenSSH installation guide has the current screens if your Windows labels differ.
On an Ubuntu 24.04 computer only, if ssh is missing, install the client using Ubuntu’s documented package:
sudo apt update && sudo apt install openssh-client
sudo asks for administrator permission; enter your computer’s login password if prompted, even though typing is invisible. Approve the package installation with Y when asked. After it finishes, repeat ssh -V. If installation fails or you lack administrator permission, resolve that with your computer’s administrator before renting a server. Skip this installation if the version check already worked.
Now create a key pair—a private file kept on your computer and a public file you’ll give to DigitalOcean:
ssh-keygen -t ed25519 -f "$HOME/deploy-notes-vps" -C "deploy-notes-vps"
The same command works in PowerShell and macOS/Linux terminals. $HOME means your user folder. When asked for a passphrase, enter a new one and enter it again; characters may not appear as you type. Keep that passphrase safe: you’ll need it when connecting.
If asked to overwrite an existing file, answer n. Don’t replace a key you might already use. If you previously created this exact key for the walkthrough, reuse it; otherwise choose a different filename and use that same name in the commands below.
Successful output says where two files were saved:
deploy-notes-vpsis the private key. Keep it on this computer; don’t paste it into a website or send it to anyone.deploy-notes-vps.pubis the public key. This is the one you can upload.
Display the public key:
cat "$HOME/deploy-notes-vps.pub"
Copy the whole line beginning with ssh-ed25519, through the final deploy-notes-vps label. Keep this terminal open. The random-looking fingerprint shown during key creation belongs to your login key; later we’ll check a different fingerprint that identifies the server.
2. Create one Ubuntu Droplet
Open DigitalOcean, sign up if you don’t have an account, and complete its email and billing checks. Account verification and accepted payment options can vary; finish the prompts in your own account before continuing. This guide doesn’t assume a free-trial credit. Usage is normally invoiced monthly, and account-specific payment checks or earlier charges may apply; review the displayed terms and billing information before creating the server.
In the control panel, use Create → Droplets. Use these choices:
| Setting | Choose |
|---|---|
| Region | New York → NYC3 is our example, not a requirement; see below if unavailable |
| Image | Ubuntu 24.04 (LTS) x64, a plain OS image |
| Configuration | Bundled, if shown |
| Plan | Shared CPU → Basic → Regular, 1 GiB / 1 vCPU / 25 GiB SSD, listed at $6/month |
| Authentication | SSH Keys; add and select the public key from step 1 |
| Networking | Keep Public IPv4 enabled; leave IPv6 off |
| Extras | No volume, automated backups, managed database or startup script; monitoring can stay off |
| Final details | 1 Droplet, hostname python-vps, your current/default project; no tags needed |
Ubuntu 24.04 matches our Python guides. Don’t select a newer version just because it’s offered first. Use Bundled rather than configuring separate v5 resources.
If NYC3 or the listed configuration isn’t available: return to Choose Region and try another region offered in your account, preferably near you. Recheck Ubuntu 24.04 x64, Bundled → Basic → Regular, 1 GiB / 1 vCPU / 25 GiB, and the $6 monthly base price after changing regions; don’t accept changed defaults. Another region isn’t guaranteed to have this combination. If you can’t find it at that price, don’t click Create Droplet. Check the current creation documentation and ask provider support about availability, or try again later. Switching the OS, plan type or budget is a separate decision, not a required step in this guide.
For the key, click Add SSH Key, paste only the .pub line, give it a recognizable name such as My computer, and save it. Make sure that key is selected for this Droplet. The server will then recognize your private key when you connect; you won’t need a root password.
Review the summary: one server, Ubuntu 24.04, the intended $6 base plan, public IPv4 and your selected key. Paid backups add a charge; a volume is extra disk space you don’t need for this setup. If the price differs, resolve that before proceeding. Clicking Create Droplet starts paid usage.
Wait until creation finishes, then open python-vps. Copy its Public IPv4 address, not its private address. You’ll use that address to find the server from your computer. Save a note with the server name, IP, login name root, and the private-key file location. Don’t put the private key or passphrase in that note.
3. Check the server’s identity and connect
Before accepting a new SSH connection, we’ll compare a short identifier called a fingerprint. It helps you check that you’re connecting to the server shown in your authenticated DigitalOcean account.
On the Droplet’s page, click Web Console. This opens a terminal on the server in your browser. If asked for a user, use root. In that browser console, run:
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
The result includes SHA256: followed by letters, numbers and symbols, and ends with (ED25519). Keep that result visible. You’re reading the server’s public identity, not displaying a private key. If the console doesn’t open, use the Droplet Console help before proceeding; don’t skip the identity check.
Return to the terminal on your own computer. Replace YOUR_SERVER_IP below with the public IPv4 you copied—without adding https:// or angle brackets:
ssh -o HostKeyAlgorithms=ssh-ed25519 -i "$HOME/deploy-notes-vps" root@YOUR_SERVER_IP
Here, -i selects your private key, root is the initial administrator account, and the HostKeyAlgorithms option asks for the same kind of server key you just checked.
On the first connection, SSH asks whether to trust the host. Compare its entire SHA256 fingerprint with the one in the browser console. If they match, type yes and press Enter. If they differ, cancel with Ctrl+C and recheck the server and IP; don’t accept a mismatch. Enter your key’s passphrase when requested. Invisible typing is normal.
You should reach a prompt resembling root@python-vps:~#. Commands now run on the VPS, not your laptop. root can change anything on it, so use this account for setup rather than running the eventual Python job as root.
4. Confirm the result and choose your next step
In the connected terminal, run:
whoami
cat /etc/os-release
The first result should be root. The second should contain ID=ubuntu and VERSION_ID="24.04". A longer name such as Ubuntu 24.04.x LTS is fine. If the version differs, don’t apply the companion instructions as though it were the selected environment; check which server and image you created first.
You now have the result this guide aimed for: a server address, your login key, and a verified administrator session on Ubuntu 24.04. You haven’t installed or started a Python job yet.
Keep this terminal open and choose one path:
- A script that stays running, such as a website checker: follow How to run a Python script 24/7 on a VPS. Choose your file, then continue with its Ubuntu preparation commands. You’re already connected, so skip its SSH login command.
- A script that finishes and should run again later, such as a report: follow How to schedule a Python script on a VPS. Choose your file or the small example, then continue with server preparation. Again, skip the login command because this session is already open.
Those guides install the required Python tools and run the job under a separate, limited user. You don’t need to create another server or buy a domain. Whenever either guide asks you to connect or reconnect, use the full SSH command from step 3 here, including -i and your key filename, in place of its generic login command. To disconnect now, press Ctrl+D at the server prompt; the VPS stays online and remains billable.
This first-login setup isn’t a complete maintenance plan. Before relying on the server for valuable data, arrange backups and regular security updates; DigitalOcean’s recommended setup covers additional administrator and firewall preparation. Keep a working connection open while changing access rules so you can check a second login before closing it.
If the connection fails
| What you see | What to check first |
|---|---|
Identity file ... not accessible |
Run the command on the computer where you made the key. Check the filename after -i; it must be the private file without .pub. |
Permission denied (publickey) |
Use root, the correct server IP and the matching private key. Check that you selected its public key during creation. Adding a key to the account afterward does not install it on an existing server; use DigitalOcean’s key instructions if you missed it. |
| Connection timed out or refused | Check that creation has finished, the server is on, and you’re using its public IPv4. Try Web Console. If that works, your local network or an added firewall may block SSH; don’t delete/recreate the VPS just to retry. |
Host fingerprint differs or REMOTE HOST IDENTIFICATION HAS CHANGED |
Stop. Check the IP and whether the server was rebuilt. Verify its identity through your provider before changing saved trust information; don’t disable host-key checking. |
When you’re finished: stop future charges
If you’re only trying this out, remove the server when you no longer need it. Powering it off does not stop billing. Deletion permanently removes its files, so copy anything you need to your computer first.
In DigitalOcean, open python-vps, go to Settings → Destroy, then the Destroy tab. Confirm the server name and destroy it. Check that it has disappeared from your Droplets list. If you added snapshots, volumes or other resources outside this walkthrough, inspect them too: they are not all removed automatically. See the deletion instructions.
Finally, review your account’s billing and resource list for anything still active. Deleting the server stops future compute usage; it does not cancel charges already incurred or other separately billed resources.
Sources and useful links
- Droplet prices and billing rules — check the selected plan, minimum charge and why switching off isn’t enough.
- Create a Droplet and available Ubuntu images — current control-panel choices and supported OS versions.
- Create an SSH key and connect with OpenSSH — more detail on the two halves of login and the first connection.
- Droplet Console — browser access when you need to check the server separately from your local SSH connection.
- Destroy a Droplet — cleanup and the resources that can remain afterward.