Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Comprehensive Guide: Secure Connection to Your Linux Server by Arjun Singh Bhella

Unix Project: Research/Tutorial

Table of Contents

Introduction

Welcome to the comprehensive guide on securely connecting to your Linux server. This guide is tailored for beginners, providing step-by-step instructions and insights to enhance your server's security using SSH. Also, some basic knowledge I picked up doing research on Backups, including popular tools and routines, as well as basic knowledge on

Understanding SSH

Before You Dive In

Before making any changes to your SSH configuration, it's crucial to proceed with caution. Consider having a second terminal session open to your server as a safety net, preventing potential lockouts during the process.

Unlocking the Power of SSH Keys

Why Opt for SSH Keys?

Embracing SSH keys offers a significant boost in security and user convenience compared to traditional passwords. This cryptographic pair, consisting of a public key for encryption and a private key for decryption, forms the backbone of secure SSH connections.

How SSH Keys Work

SSH keys operate based on a public-private key pair. The public key encrypts data, while the private key decrypts it. During the connection process, the server encrypts a challenge message using the public key, and the client decrypts it with the private key, establishing a secure connection.

Generating Your SSH Keys

Objectives

  • Create robust Ed25519 SSH keys for authentication.

Step-by-Step Guide

  1. Open your local machine's terminal and execute the following command to generate Ed25519 keys:

    ssh-keygen -t ed25519

    Follow the prompts to determine where to save the keys. The private key remains on your local machine, while the public key is appended to ~/.ssh/authorized_keys on the server.

Additional Tips

  • Consider using ssh-copy-id for secure and efficient key transfer.
  • Explore passphrases for added security, keeping your private key safe.

Implementing Secure 2FA/MFA

Enhance your server's security by implementing Two-Factor Authentication (2FA) or Multi-Factor Authentication (MFA) specifically for SSH access.

Why Consider 2FA/MFA?

While SSH provides a robust security layer, adding an extra authentication factor, such as a time-based token, significantly strengthens your defense against unauthorized access.

How to Implement 2FA/MFA

  1. Install the libpam-google-authenticator module:

    On Debian-based systems:

    sudo apt install libpam-google-authenticator
  2. Run google-authenticator for the user you want to enable 2FA/MFA:

    google-authenticator

    Follow the prompts to set up the authentication token.

  3. Modify the PAM configuration for SSH (/etc/pam.d/sshd) to include:

    auth       required     pam_google_authenticator.so nullok
  4. Update /etc/ssh/sshd_config to enable Challenge-Response Authentication:

    ChallengeResponseAuthentication yes
  5. Restart the SSH service:

    sudo service ssh restart

Backups: Popular Tools and Policies/Routines

Backups: Popular Tools and Policies/Routines

Introduction-1

This README explores fundamental aspects of data backups, covering popular tools and essential practices to safeguard your valuable information.

Popular Backup Tools

rsync

Rsync is a versatile command-line tool for efficient file synchronization. It simplifies copying and updating files by transmitting only the differences between the source and destination.

Duplicity

Duplicity combines the power of the rsync algorithm with encryption. It supports various storage options, making it a reliable choice for securing your data.

BackupPC

BackupPC is a high-performance system designed for backing up PCs to a server's disk. It features a user-friendly web interface and supports essential features like pooling, compression, and full/incremental backups.

Backups Tutorial

Full Backup vs. Incremental Backup

Choosing between a full backup and an incremental backup depends on factors like storage capacity and backup frequency. Full backups copy all data, while incremental backups only copy changes, optimizing storage.

Retention Policies

Retention policies determine how long backups are retained. Common strategies include daily, weekly, and monthly backups with varying retention periods, balancing data preservation and storage efficiency.

Simple Backup Tutorial: Using rsync

  1. Open a terminal on your local machine.

  2. Use the following command to perform a simple backup using rsync:

    rsync -avz /path/to/source/ user@remote_server:/path/to/destination/

    This command syncs the source directory to the destination directory on the remote server.

  3. Monitor the progress and ensure the backup completes successfully.

Backup Policies Tutorial

Setting Up Retention Policies

  1. Determine your retention requirements, e.g., daily, weekly, and monthly backups.

  2. Use a tool like BackupPC to configure retention policies based on your requirements.

  3. Regularly review and adjust retention policies to balance data preservation and storage efficiency.

Backup Routines Tutorial

Automating Regular Backups with cron

  1. Open your server's crontab configuration:

    crontab -e
  2. Add a cron job entry for your backup routine. For example, to run a backup every day at 3 AM:

    0 3 * * * rsync -avz /path/to/source/ /path/to/backup/

    Save and exit the crontab editor.

Introduction-2

This section covers common tasks to enhance the security of your UNIX server. Implementing these measures contributes to a robust defense against potential threats.

System Security: Common Tasks to Harden a UNIX Server

Update and Patch Regularly

Regularly updating and patching your server's operating system and installed software is crucial for addressing security vulnerabilities. Utilize package managers to streamline the update process.

Updating Your System with apt (Debian/Ubuntu)

  1. Open a terminal.

  2. Run the following commands:

    sudo apt update
    sudo apt upgrade
  3. Follow the prompts to install updates.

Firewall Configuration

Configure a firewall to control incoming and outgoing network traffic. Tools like ufw (Uncomplicated Firewall) simplify firewall management for users who may not be familiar with complex iptables rules.

Configuring Firewall with ufw

  1. Install ufw (if not installed):

    sudo apt install ufw
  2. Enable ufw:

    sudo ufw enable
  3. Allow necessary services, e.g., SSH:

    sudo ufw allow OpenSSH

User Account Management

Practicing secure user account management involves regularly reviewing and managing user access. Remove unnecessary accounts, enforce strong password policies, and consider implementing periodic access reviews.

Managing User Accounts with userdel

  1. Open a terminal.

  2. Run the following command to delete a user:

    sudo userdel -r username

    Replace "username" with the actual username.

Simple Security Measures

Implement simple security measures like disabling unnecessary services, restricting unnecessary access, and regularly auditing system logs for unusual activities.

Disabling Unnecessary Services

  1. Identify unnecessary services:

    sudo systemctl list-unit-files --type=service
  2. Disable a service:

    sudo systemctl disable servicename

    Replace "servicename" with the actual service name.

Security Measures Tutorial

Explore tutorials on implementing security measures for your UNIX server. Learn how to update, configure a firewall, manage user accounts, and implement simple security practices.

Conclusion

In conclusion, this comprehensive guide empowers you with essential knowledge to secure your Linux server effectively. From establishing secure SSH connections and implementing 2FA/MFA to employing robust backup strategies and enhancing overall system security, these practices form a resilient foundation for a well-protected server environment.

Key Takeaways:

  • Secure SSH Access: Utilize SSH keys for enhanced security and user convenience.
  • 2FA/MFA Implementation: Strengthen server security by adding an extra authentication factor.
  • Effective Backups: Safeguard valuable data with popular tools and best backup practices.
  • System Security Measures: Harden your UNIX server with simple yet impactful security tasks.

This README introduces essential backup tools, highlights key practices, and emphasizes the importance of a comprehensive backup strategy for safeguarding your data. This README introduces essential backup tools, highlights key practices, and emphasizes the importance of a comprehensive backup strategy for safeguarding your data.

License - This README is provided under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors