Logo of the site

My cheatsheet

VPS cheatsheet

Basic VPS commands and configuration quick reference

# Getting started

What is a vps?

A Virtual Private Server (VPS) is a virtualized server that mimics a dedicated server within a shared hosting environment. It provides users with root access, allowing them to install and configure software, manage server resources, and host websites or applications. VPS offers a balance between cost and control, making it suitable for businesses and developers needing more flexibility and performance than shared hosting but at a lower cost than a dedicated server.

Operative System

A VPS can have various types of operating systems, depending on the user's needs. The most common types are:

  • Linux The most popular choice for VPS. Common distributions include: Ubuntu, CentOS, Debian, Fedora
  • Windows Preferred for running specific Windows applications or using technologies like ASP.NET.
  • BSD Known for stability and security, with options like FreeBSD.

Establish a secure SSH connection

To establish a secure SSH connection, generate first a Private SSH Key and a Public SSH Key, then copy the Public Key to the VPS

ssh-copy-id -i key_name.pub root@IP_ADDRESS

If the above command does not work, a manual copy of the key can be executed

cat key_name.pub | ssh root@IP_ADDRESS "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"

The first time connecting, the root password of the VPS must be inserted. After, the connection with the VPS can be established with the command

ssh -i key_name.pem root@IP_ADDRESS