Connecting to a Cloud Server
Cloud servers (Virtual Private Servers, or VPS) let you run applications and websites on remote infrastructure without managing physical hardware. This guide covers the three most common ways to connect to a cloud server — SSH (Linux/Mac command line), PuTTY (Windows GUI), and Remote Desktop (Windows servers) — and how to keep your connection secure.
1. What You Need Before Connecting
Gather the following before attempting a connection:
- Server IP address: Provided by your cloud provider (e.g., AWS, DigitalOcean, Vultr, Linode) in the instance dashboard.
- Username: Typically
root(initial setup),ubuntu(Ubuntu servers on AWS/DigitalOcean), orec2-user(Amazon Linux). - Authentication method: Either an SSH key pair (recommended) or a password set during server creation.
- SSH port: Default is port 22. Some providers or admins change this for security — confirm with your provider.
- Firewall rules: Ensure port 22 (SSH) or 3389 (RDP) is open in your cloud provider's security group or firewall rules.
2. Connecting via SSH (Linux / macOS)
Open the Terminal and run:
# Using an SSH key
ssh -i /path/to/your-key.pem username@SERVER_IP
# Using a password (less secure)
ssh username@SERVER_IP
Replace username with your actual username and SERVER_IP with the IP address from your cloud dashboard.
On first connection, you will see a host key warning:
The authenticity of host '203.0.113.10' can't be established.
ECDSA key fingerprint is SHA256:abc123...
Are you sure you want to continue connecting (yes/no)?
Type yes and press Enter. The host key is saved to ~/.ssh/known_hosts. If you see this warning again for a server you've already connected to, it may indicate a man-in-the-middle attack — verify the server's IP has not changed before proceeding.
Set correct key file permissions
SSH key files must have restricted permissions or the SSH client will refuse to use them. Run: chmod 400 /path/to/your-key.pem before connecting.
3. Connecting via SSH on Windows
Windows 10 and later include a built-in OpenSSH client. Open PowerShell or Command Prompt and use the same syntax as above:
ssh -i C:\Users\YourName\.ssh\your-key.pem username@SERVER_IP
Alternatively, use PuTTY for a graphical interface:
- Download and install PuTTY from the official PuTTY website.
- If you have a
.pemkey, open PuTTYgen, load the key, and save it as a.ppkfile. - Open PuTTY, enter your server IP in "Host Name", set port to 22, and connection type to SSH.
- Go to Connection → SSH → Auth → Credentials and browse to your
.ppkfile. - Click Open, accept the host key warning, and enter your username when prompted.
4. Connecting to a Windows Server via RDP
If your cloud server runs Windows Server, use Remote Desktop Protocol (RDP):
- Open Remote Desktop Connection (search "mstsc" in the Start menu).
- Enter your server IP address in the "Computer" field.
- Click Show Options → enter your username (e.g.,
Administrator). - Click Connect and enter the password when prompted.
- Accept the certificate warning on first connection.
From macOS, download Microsoft Remote Desktop from the Mac App Store and follow a similar process.
5. Setting Up SSH Key Authentication
SSH key authentication is more secure than passwords. Here is how to set it up:
# 1. Generate a key pair on your local machine
ssh-keygen -t ed25519 -C "your@email.com"
# 2. Copy your public key to the server
ssh-copy-id username@SERVER_IP
# 3. Test the key-based login
ssh username@SERVER_IP
After confirming key-based login works, disable password authentication on the server:
# Edit /etc/ssh/sshd_config on the server
PasswordAuthentication no
# Restart SSH service
sudo systemctl restart sshd
6. Security Best Practices
- Change the default SSH port: Change from 22 to a non-standard port (e.g., 2222) in
/etc/ssh/sshd_configto reduce automated scanning attacks. - Disable root login: Set
PermitRootLogin noin sshd_config. Create a separate sudo user for administration. - Use Fail2Ban: Install Fail2Ban to automatically block IP addresses after repeated failed login attempts.
- Keep your keys safe: Never share your private key. Store it in
~/.ssh/with 400 permissions. Back up to an encrypted location. - Use firewall rules: Restrict SSH access to your office IP range via your cloud provider's security group — do not leave port 22 open to the entire internet.
7. Troubleshooting Connection Issues
| Error | Likely Cause | Fix |
|---|---|---|
| Connection refused | SSH not running or port blocked | Check cloud firewall rules; verify sshd is running on the server |
| Permission denied (publickey) | Wrong key or username | Verify you are using the correct .pem/.ppk file and the right username |
| Host key verification failed | Server was recreated or IP changed | Remove the old entry from ~/.ssh/known_hosts and reconnect |
| Connection times out | Wrong IP or firewall blocking | Confirm the server IP; check the cloud provider's inbound firewall rules |
| Key too open (bad permissions) | Key file permissions too broad | Run chmod 400 your-key.pem |
Was this article helpful?
What can we improve?
