Skip to content

Instantly share code, notes, and snippets.

@itsabdelrahman
Last active April 1, 2024 08:00
Show Gist options
  • Save itsabdelrahman/852f0d56b47255d2f3cca6e8a3e5172b to your computer and use it in GitHub Desktop.
Save itsabdelrahman/852f0d56b47255d2f3cca6e8a3e5172b to your computer and use it in GitHub Desktop.
Linux Debian Server Setup

Linux Ubuntu/Debian Server Setup

On remote machine

As root

  1. Change root password
    • $ passwd
  2. Create user & their home directory
    • $ useradd -m <username>
  3. Set user's password
    • $ passwd <username>
  4. Make user a sudoer
    • $ usermod -aG sudo <username>
  5. Set user's shell as bash
    • $ chsh -s /bin/bash <username>

As <username>

  1. Install essentials: $ sudo apt update && sudo apt upgrade && sudo apt install nano curl git htop exa
  2. Enable passwordless sudo for user
    • $ sudo nano /etc/sudoers.d/<username>
    • Add: <username> ALL=(ALL) NOPASSWD: ALL

On local machine

  1. Copy SSH public key to remote machine's authorized keys
    • $ ssh-copy-id -i <public-key-path> <username>@<remote-machine-ip-address>

On remote machine

As <username>

  1. Edit SSH daemon configuration
    • $ sudo nano /etc/ssh/sshd_config
    • Disable root access
      • Edit: PermitRootLogin no
    • Disable password authentication
      • Edit: PasswordAuthentication no
    • Restart ssh service: $ sudo /etc/init.d/ssh restart
  2. Install zsh and ohmyzsh
  3. Install Homebrew
  4. Install essentials: brew install micro fzf bat restic just
  5. Install Docker
  6. Schedule cleanup of unused Docker images
    • Open crontab
      • $ crontab -e
    • Create a new cronjob
      • Append: 0 1 * * * sudo docker system prune -af
  7. Give sudo (secure_path in /etc/sudoers) and crontab (PATH= in crontab -e) access to tools in PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment