Files
the_information_nexus/tech_docs/linux/arch_deploy.md

9.9 KiB

Theme: Space Exploration

Username: astronaut

Password: stardust123 (Note: Use a strong password in a real setup)

Hostname: spaceship

Domain Name: galaxy.local

Step-by-Step Opinionated Arch Linux Setup with Space Theme

Absolutely, minimizing direct interaction with the device is a great idea, especially for convenience and security. Let's prioritize getting SSH set up quickly so you can manage your system remotely. We'll follow through with the initial setup and then immediately configure SSH to ensure you can access your system remotely as soon as possible.

Step-by-Step Opinionated Arch Linux Setup with Quick SSH Access

Step 1: Verify Boot Mode

Ensure your system is booting in UEFI mode:

ls /sys/firmware/efi/efivars

If this directory exists, you are in UEFI mode.

Step 2: Partition the Disk

Format and mount the partitions:

mkfs.fat -F32 /dev/sda1  # EFI partition
mkswap /dev/sda2         # Swap partition
mkfs.ext4 /dev/sda3      # Root partition

mount /dev/sda3 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/sda2

Step 3: Install the Base System

Install the base packages:

pacstrap /mnt base linux linux-firmware vim openssh

Step 4: Generate fstab

Generate the fstab file:

genfstab -U /mnt >> /mnt/etc/fstab

Step 5: Chroot into the New System

Change root into the new system:

arch-chroot /mnt

Step 6: Set Locale and Timezone

  1. Set locale:

    • Edit /etc/locale.gen to uncomment your locale (e.g., en_US.UTF-8):
      vim /etc/locale.gen
      
    • Generate the locale:
      locale-gen
      
  2. Set timezone:

    ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
    hwclock --systohc
    

Step 7: Set Hostname and Hosts

  1. Set hostname:

    echo "spaceship.galaxy.local" > /etc/hostname
    
  2. Edit /etc/hosts:

    vim /etc/hosts
    

    Add the following lines:

    127.0.0.1	localhost
    ::1		localhost
    127.0.1.1	spaceship.galaxy.local	spaceship
    

Step 8: Set Root Password

Set a strong password for the root user:

passwd

For this guide, we'll use stardust123 as the root password.

Step 9: Create a Regular User Account

Create a user account and add it to the sudo group:

useradd -m astronaut
usermod -aG sudo astronaut
passwd astronaut

For this guide, we'll use stardust123 as the user password.

Step 10: Install Bootloader

Install GRUB for UEFI:

pacman -S efibootmgr grub
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ArchLinux
grub-mkconfig -o /boot/grub/grub.cfg

Step 11: Configure SSH

  1. Configure SSH:

    • Open the SSH configuration file:
      sudo nano /etc/ssh/sshd_config
      
    • Make the following changes:
      • Change PermitRootLogin to prohibit-password.
      • Change PasswordAuthentication to no.
      • Add PubkeyAuthentication yes.
      • Add AuthorizedKeysFile .ssh/authorized_keys.
    • Save the file and restart the SSH service:
      sudo systemctl enable sshd
      sudo systemctl start sshd
      
  2. Set Up SSH Keys:

    • Generate an SSH key pair on your client machine:
      ssh-keygen -t rsa -b 4096
      
    • Copy the public key to your Arch Linux server:
      ssh-copy-id astronaut@your_server_ip
      

Step 12: Exit Chroot and Reboot

Exit the chroot environment and reboot:

exit
umount -R /mnt
reboot

Post-Reboot Configuration

Step 13: Verify SSH Access

After rebooting, try to SSH into your new Arch Linux system from another machine:

ssh astronaut@your_server_ip

Replace your_server_ip with the actual IP address of your Arch Linux system.

Step 14: Network Configuration

  1. Install NetworkManager:

    sudo pacman -S networkmanager
    
  2. Enable NetworkManager:

    sudo systemctl enable NetworkManager
    sudo systemctl start NetworkManager
    
  3. Configure DHCP for Ethernet:

    • Ensure the interface enp0s25 (or whatever your interface is named) is set to use DHCP:
      nmcli d
      nmcli con mod enp0s25 ipv4.method auto
      nmcli con up enp0s25
      

Final Notes

  • Firewall: Consider setting up a firewall using ufw or firewalld.
  • Regular Updates: Regularly update your system using sudo pacman -Syu.
  • Backup: Regularly back up important data.

By following these steps, you should have a secure and accessible Arch Linux system up and running quickly. You can now manage your system remotely via SSH, minimizing the need for direct interaction.


Step 1: Verify Boot Mode

Ensure your system is booting in UEFI mode:

ls /sys/firmware/efi/efivars

If this directory exists, you are in UEFI mode.

Step 2: Partition the Disk

Format and mount the partitions:

mkfs.fat -F32 /dev/sda1  # EFI partition
mkswap /dev/sda2         # Swap partition
mkfs.ext4 /dev/sda3      # Root partition

mount /dev/sda3 /mnt
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/sda2

Step 3: Install the Base System

Install the base packages:

pacstrap /mnt base linux linux-firmware vim

Step 4: Generate fstab

Generate the fstab file:

genfstab -U /mnt >> /mnt/etc/fstab

Step 5: Chroot into the New System

Change root into the new system:

arch-chroot /mnt

Step 6: Set Locale and Timezone

  1. Set locale:

    • Edit /etc/locale.gen to uncomment your locale (e.g., en_US.UTF-8):
      vim /etc/locale.gen
      
    • Generate the locale:
      locale-gen
      
  2. Set timezone:

    ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
    hwclock --systohc
    

Step 7: Set Hostname and Hosts

  1. Set hostname:

    echo "spaceship.galaxy.local" > /etc/hostname
    
  2. Edit /etc/hosts:

    vim /etc/hosts
    

    Add the following lines:

    127.0.0.1	localhost
    ::1		localhost
    127.0.1.1	spaceship.galaxy.local	spaceship
    

Step 8: Set Root Password

Set a strong password for the root user:

passwd

For this guide, we'll use stardust123 as the root password.

Step 9: Create a Regular User Account

Create a user account and add it to the sudo group:

useradd -m astronaut
usermod -aG sudo astronaut
passwd astronaut

For this guide, we'll use stardust123 as the user password.

Step 10: Install Bootloader

Install GRUB for UEFI:

pacman -S efibootmgr grub
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ArchLinux
grub-mkconfig -o /boot/grub/grub.cfg

Step 11: Exit Chroot and Reboot

Exit the chroot environment and reboot:

exit
umount -R /mnt
reboot

Post-Installation Configuration

Step 12: Secure SSH

  1. Install SSH:

    sudo pacman -S openssh
    
  2. Configure SSH:

    • Open the SSH configuration file:
      sudo nano /etc/ssh/sshd_config
      
    • Make the following changes:
      • Change PermitRootLogin to no.
      • Change PasswordAuthentication to no.
      • Add PubkeyAuthentication yes.
      • Add AuthorizedKeysFile .ssh/authorized_keys.
    • Save the file and restart the SSH service:
      sudo systemctl enable sshd
      sudo systemctl start sshd
      
  3. Set Up SSH Keys:

    • Generate an SSH key pair on your client machine:
      ssh-keygen -t rsa -b 4096
      
    • Copy the public key to your Arch Linux server:
      ssh-copy-id astronaut@your_server_ip
      

Step 13: Network Configuration

  1. Install NetworkManager:

    sudo pacman -S networkmanager
    
  2. Enable NetworkManager:

    sudo systemctl enable NetworkManager
    sudo systemctl start NetworkManager
    
  3. Configure DHCP for Ethernet:

    • Ensure the interface enp0s25 (or whatever your interface is named) is set to use DHCP:
      nmcli d
      nmcli con mod enp0s25 ipv4.method auto
      nmcli con up enp0s25
      

Step 14: Install a Minimal Desktop Environment (Optional)

If you want a minimal desktop environment, consider installing Xorg and a lightweight window manager like i3 or dwm.

  1. Install Xorg:

    sudo pacman -S xorg-server xorg-xinit
    
  2. Install a Window Manager:

    sudo pacman -S i3
    
  3. Configure Xinit:

    • Create a .xinitrc file in your home directory:
      echo "exec i3" > ~/.xinitrc
      
  4. Start X:

    startx
    

Final Notes

  • Firewall: Consider setting up a firewall using ufw or firewalld.
  • Regular Updates: Regularly update your system using sudo pacman -Syu.
  • Backup: Regularly back up important data.

This setup guide provides a secure, minimal, and opinionated configuration for Arch Linux with a fun space-themed scheme. Adjustments can be made based on your specific needs and preferences.


Sure, let's refactor that section to use UTC as the timezone. This is a common choice for servers and can simplify time management, especially in multi-timezone environments.

Refactored Section for Setting Timezone to UTC

ln -sf /usr/share/zoneinfo/UTC /etc/localtime
hwclock --systohc

Updated Step-by-Step Guide with UTC Timezone

Step 6: Set Locale and Timezone

  1. Set locale:

    • Edit /etc/locale.gen to uncomment your locale (e.g., en_US.UTF-8):
      vim /etc/locale.gen
      
    • Generate the locale:
      locale-gen
      
  2. Set timezone to UTC:

    ln -sf /usr/share/zoneinfo/UTC /etc/localtime
    hwclock --systohc
    

This change ensures that your system uses Coordinated Universal Time (UTC) as the timezone. This is particularly useful for servers and systems that need to interact with other systems across different timezones.