Lesson 2: Get a VPS & First SSH Connection
Lesson 2: Get a VPS & First SSH Connection
Choose a VPS Provider
| Provider | Free Tier | Cheapest Paid | Notes |
|---|---|---|---|
| Oracle Cloud | 4 ARM Ampere + 24GB RAM | ~$3/mo | Generous free tier, complex signup |
| CloudCone | No | $1.79/mo | Cheap, US-based |
| RackNerd | No | $10-15/yr | Very cheap annual deals |
| Hetzner | No | €4.51/mo | Excellent EU performance |
| DigitalOcean | No | $4/mo | Simple, good docs |
Recommendation: Oracle Cloud Free Tier (4 ARM cores, 24GB RAM) for learning — it's free forever.
Generate SSH Keys
ssh-keygen -t ed25519 -C "your@email.com"
- Ed25519: Modern, fast, secure (preferred over RSA)
- Save to default
~/.ssh/id_ed25519 - Use a passphrase for extra security
Copy Public Key to VPS
ssh-copy-id ubuntu@YOUR_VPS_IP
Enter your VPS password once. After this, ssh ubuntu@IP works without password.
SSH Config for Convenience
Edit ~/.ssh/config:
Host devops
HostName 129.159.8.43
User ubuntu
IdentityFile ~/.ssh/id_ed25519
ForwardAgent yes
Now just type ssh devops.
First Login & Basic Security
ssh devops
# Update system
sudo apt update && sudo apt upgrade -y
# Create a non-root user (if not ubuntu)
sudo adduser devops
sudo usermod -aG sudo devops
# Copy your key to new user
ssh-copy-id devops@YOUR_VPS_IP
Next: Harden SSH — disable root login, password auth, install fail2ban (Lesson 9 covers systemd services).
Cheap VPS for Practice
- Oracle Free Tier: Always free, 4 OCPU ARM, 24GB RAM
- CloudCone: ~$1.79/mo, pay hourly
- RackNerd: ~$15/yr on Black Friday deals
💻 实战命令速查
ssh-keygen -t ed25519 -C "your@email.com"
Generate Ed25519 SSH key pair
$ ssh-keygen -t ed25519 -C "me@example.com"
Generating public/private ed25519 key pair...
Enter file to save (/home/user/.ssh/id_ed25519):
Your public key saved in /home/user/.ssh/id_ed25519.pub
ssh-copy-id user@your-vps-ip
Copy public key to VPS for passwordless login
$ ssh-copy-id ubuntu@129.159.8.43
Number of key(s) added: 1
ssh user@your-vps-ip
Connect to VPS via SSH
$ ssh ubuntu@129.159.8.43
Welcome to Ubuntu 24.04 LTS
ubuntu@devops:~$
cat ~/.ssh/config
View/edit SSH config for aliases
Host devops
HostName 129.159.8.43
User ubuntu
IdentityFile ~/.ssh/id_ed25519