Skip to main content

Secure Your Server

This guide covers the essential steps to secure your Next Hat server.

Create a dedicated user

Avoid using the root account for daily operations. Instead, create a dedicated user with sudo and nanocl privileges.

  1. Create a new user with a home directory:
adduser your_username
  1. Add the user to the sudo group:
usermod -aG sudo your_username
  1. Add the user to the nanocl group:
usermod -aG nanocl your_username

Replace your_username with your preferred username.

Set up SSH key authentication

For improved security, disable password authentication and use SSH keys instead.

  1. Generate an SSH key pair on your local machine if you haven't already:
ssh-keygen -t ed25519
caution

Never use an empty passphrase for your SSH key. If your private key is compromised, attackers could gain access to your server.

  1. Copy the public key to your server:
ssh-copy-id -i ~/.ssh/<your_key>.pub your_username@your_server
  1. Edit the SSH configuration file on your server:
sudo vim /etc/ssh/sshd_config
  1. Locate and update the following lines:
PasswordAuthentication no
PermitRootLogin no
  1. Restart the SSH service to apply the changes:
sudo systemctl restart ssh