Reinstalling a server's operating system safely
A reinstall wipes the disk and gives you a clean OS. How to prepare, run it from the console, and get back in afterwards.

Reinstalling (or rebuilding) a Cloud Server gives you a fresh operating system on the same server and plan. It is the quickest way to recover from a compromised or badly broken system, or to switch from one OS to another. It is also irreversible, so it pays to prepare.
What a reinstall does
- Erases the primary disk. Every file, database, user and configuration on it is destroyed and cannot be recovered.
- Keeps the server itself: it stays in the same region on the same plan and billing.
- Resets access. The root password and SSH host keys change.
Before you start
Copy off everything you need
There is no undo. Copy your data somewhere else first. Two common approaches:
# Dump databasesmysqldump --all-databases --single-transaction | gzip > /root/all-databases.sql.gz # Pull files and the dump to your own machinersync -avz [email protected]:/var/www/ ./server-backup/www/rsync -avz [email protected]:/etc/ ./server-backup/etc/rsync -avz [email protected]:/root/all-databases.sql.gz ./server-backup/
For off-site copies you can keep long term, push them to Object Storage with any S3-compatible tool.
Tip: open your backup and check it before you reinstall. Restore a database dump into a local MySQL, or list the archive. A backup you have never restored is a hope, not a backup.
Write down what you configured
Firewall rules, cron jobs, users and installed packages do not survive a reinstall. These commands capture most of it:
ufw status verbose > ~/firewall.txtcrontab -l > ~/crontab.txtapt-mark showmanual > ~/packages.txt
Run the reinstall
- In the console, open your server and choose Open Console.
- Choose the reinstall option and pick an operating system image, such as Ubuntu 22.04 or 20.04, or Windows Server 2022 or 2019.
- Read the confirmation carefully, then confirm. Nothing is erased until you do.
The reinstall takes a few minutes. Wait for the server to show as running again before you try to connect.
Prefer a long-term-support release unless you have a specific reason not to. LTS releases get security updates for far longer.
Get back in
Set a root password
Open the server page and choose Reset root password. The new password is shown once, so save it straight away.
Clear the old host key
Your SSH client remembers the server's previous fingerprint and will refuse to connect, warning that the host identification has changed. That is expected after a reinstall. Remove the old entry:
ssh-keygen -R 203.0.113.10
Then connect and accept the new fingerprint:
ssh [email protected]
Rebuild the basics
apt update && apt upgrade -yhostnamectl set-hostname server1.example.comssh-copy-id [email protected] # run this from your own machineufw allow OpenSSH && ufw enable
Then restore your data and reapply the configuration you noted down.
If you cannot connect afterwards
- Connection refused or timed out. The reinstall is still finishing. Give it a few more minutes.
- "Remote host identification has changed". Run
ssh-keygen -Ras shown above. - Password rejected. Reset the root password again and paste it carefully.
- Still nothing. Use Open Console to see what the server is doing. See Locked out of your server?.
Next steps
- Set up key login on the fresh system: SSH keys.
- Keep data that matters off the server entirely with Managed Databases and Object Storage.
- Want a clean server next to the old one instead? Deploy a new Cloud Server and move a Floating IP across when it is ready.
Try it yourself
Cloud Servers start at $3.25/mo, billed by the hour.