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.
- Create a new user with a home directory:
adduser your_username
- Add the user to the sudo group:
usermod -aG sudo your_username
- 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.
- 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.
- Copy the public key to your server:
ssh-copy-id -i ~/.ssh/<your_key>.pub your_username@your_server
- Edit the SSH configuration file on your server:
sudo vim /etc/ssh/sshd_config
- Locate and update the following lines:
PasswordAuthentication no
PermitRootLogin no
- Restart the SSH service to apply the changes:
sudo systemctl restart ssh