Skip to content

Latest commit

 

History

History
110 lines (71 loc) · 2.87 KB

File metadata and controls

110 lines (71 loc) · 2.87 KB

How to Set Up and Secure Your Ubuntu Server

Introduction

This guide will show you how to prepare your Ubuntu server for development by setting up secure access with SSH keys, modifying your SSH configuration for enhanced security, and installing necessary packages through a script.

After completing this guide, you'll be able to:

  • Securely log into your server using SSH keys.
  • Configure your SSH settings for improved security.
  • Install essential packages on your server using a script.

Table of Contents

Prerequisites

Before starting, you need:

  1. An Ubuntu server with root access.
  2. A computer with SSH client software.

Step 1 - Generating and Setting Up SSH Keys

Create a secure SSH key pair on your computer:

ssh-keygen -t rsa -b 4096

Copy your public SSH key to your clipboard for easy access:

cat ~/.ssh/id_rsa.pub | pbcopy

Log into your server as the root user:

ssh root@{{ip_address}}

Set up the .ssh directory and secure it:

mkdir -p ~/.ssh && chmod 700 ~/.ssh

Paste your SSH key into the authorized_keys file:

vim ~/.ssh/authorized_keys

Then secure the file:

chmod 600 ~/.ssh/authorized_keys

Step 2 - Adjusting Your SSH Settings for Security

Important: Before proceeding, test your SSH key by logging in from another terminal tab or session to ensure you don’t lose access.

ssh root@{{ip_address}}

Once you’ve successfully logged in via SSH key, you can further enhance your SSH login security by modifying a couple of settings:

Open the SSH configuration file:

vim /etc/ssh/sshd_config

Include these lines to disable password authentication and deny empty passwords:

PasswordAuthentication no
PermitEmptyPasswords no

Save your changes and exit the editor.

Apply your new SSH configuration by restarting the service:

systemctl restart ssh

Step 3 - Installing Packages with a Script

In your Ubuntu server, run the following script to install necessary packages. This script fetches and applies an installation script directly:

curl -sSL https://raw.githubusercontent.com/MurmurationsNetwork/MurmurationsServices/main/scripts/ubuntu_setup.sh | bash

Conclusion

Your Ubuntu server is now set up with enhanced security measures and ready for development. You've implemented SSH key access, updated SSH configurations for improved security, and installed important packages.

Go to Section 2 - Setting up K3s.