Linux Cloud Server Setup: From SSH to Production in One Afternoon

A clear, repeatable path from a fresh Linux instance to a production-ready server: SSH hardening, user setup, firewall, time sync, swap and basic monitoring.

New to Alibaba Cloud? Check the latest new-user offers →

First login and SSH hardening

Create a normal user with sudo, then configure SSH to deny password login and root login. Use a key pair generated locally and copy the public key to the server.

Change the SSH port is optional; with key-only auth and a firewall restricting port 22, keeping the default port is acceptable and simpler. Enable fail2ban for extra protection on public ports.

System basics

Update the package index and install security updates. Set the correct timezone and enable NTP. Check the hostname and set it to something meaningful.

Configure swap if the instance has little memory and the workload can use it, then set swappiness conservatively so burst memory is handled without thrashing the disk.

Firewall and services

Use ufw or firewalld to allow only SSH (from your IP), HTTP/HTTPS, and any application port. Test the rules from another device before closing your own access.

Install and configure Nginx or your web stack. Keep services minimal — each open port and running daemon is an attack surface and a maintenance burden.

Monitoring from day one

Set up basic metrics collection: CPU, memory, disk, network, and service status. Alerts should reach you before users do.

Configure log rotation so logs never fill the disk, and forward important logs to a central place if you run more than one server.

Frequently Asked Questions

Which Linux distribution should I use?

Use the distribution you know best. For most users, a long-term-support release of Ubuntu, Debian, or a mainstream commercial distribution is the safest default. Match the distribution to your application stack's tested versions.

How much swap should I set?

For instances with 2-4GB RAM, 2GB of swap is a reasonable safety net. For larger memory instances, swap is rarely needed — prefer monitoring and right-sizing over relying on swap.

Do I need a control panel?

No. A panel adds convenience but also complexity and attack surface. For one or a few servers, a scripted setup (Ansible or a simple shell script) is cleaner and fully reproducible.

Prices and promotions shown on this page are indicative only — always confirm current pricing and terms on the official Alibaba Cloud website at the time of purchase.