New Virtual Machine Server Setup Checklist
Software engineer and entrepreneur based in San Francisco.
Software engineer and entrepreneur based in San Francisco.
I use a lot of checklists -- here is one of mine for setting up a new Linux virtual machine server. The commands are written for Ubuntu/Debian-based systems.
First, let's update the package lists and upgrade existing packages:
sudo apt update
sudo apt upgrade
apt update
: Updates the package list/index files from repositoriesapt upgrade
: Actually upgrades the installed packages to their latest versionsFollow these steps to install Docker properly on Ubuntu:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
To permanently change your server's hostname:
sudo hostnamectl set-hostname <<your-new-hostname>>
And update /etc/hosts
to reflect the new hostname:
sudo nano /etc/hosts
# Add/update the line:
127.0.0.1 <<your-new-hostname>>
# Create new user
sudo adduser <<new-username>>
# Add to sudo group
sudo usermod -aG sudo <<new-username>>
# Add to docker group
sudo usermod -aG docker <<new-username>>
Login as your new user above first, as you can't install homebrew as root.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
sudo apt install micro
brew install jesseduffield/lazydocker/lazydocker
brew install lazygit
ssh-keygen -t ed25519 -C "[email protected]"
Edit /etc/ssh/sshd_config
:
sudo nano /etc/ssh/sshd_config
Add/modify these important settings:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 10
For the new user:
# Create .ssh directory
sudo mkdir -p /home/<<new-username>>/.ssh
sudo chown <<new-username>>:<<new-username>> /home/<<new-username>>/.ssh
sudo chmod 700 /home/<<new-username>>/.ssh
# Copy root's authorized_keys to new user (if exists)
if [ -f /root/.ssh/authorized_keys ]; then
sudo cp /root/.ssh/authorized_keys /home/<<new-username>>/.ssh/
sudo chown <<new-username>>:<<new-username>> /home/<<new-username>>/.ssh/authorized_keys
sudo chmod 600 /home/<<new-username>>/.ssh/authorized_keys
fi
# Or manually add your public key if needed
# echo "your-public-key" | sudo tee /home/<<new-username>>/.ssh/authorized_keys
sudo systemctl restart ssh
Remember to test SSH access with your new user before closing your current session to ensure you haven't locked yourself out of the server.