diff --git a/tech_docs/linux/arch_deploy.md b/tech_docs/linux/arch_deploy.md index c0480f9..6ee7207 100644 --- a/tech_docs/linux/arch_deploy.md +++ b/tech_docs/linux/arch_deploy.md @@ -7,6 +7,179 @@ ### 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: +```bash +ls /sys/firmware/efi/efivars +``` +If this directory exists, you are in UEFI mode. + +#### Step 2: Partition the Disk +Format and mount the partitions: +```bash +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: +```bash +pacstrap /mnt base linux linux-firmware vim openssh +``` + +#### Step 4: Generate `fstab` +Generate the `fstab` file: +```bash +genfstab -U /mnt >> /mnt/etc/fstab +``` + +#### Step 5: Chroot into the New System +Change root into the new system: +```bash +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`): + ```bash + vim /etc/locale.gen + ``` + - Generate the locale: + ```bash + locale-gen + ``` + +2. **Set timezone**: + ```bash + ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime + hwclock --systohc + ``` + +#### Step 7: Set Hostname and Hosts +1. **Set hostname**: + ```bash + echo "spaceship.galaxy.local" > /etc/hostname + ``` + +2. **Edit `/etc/hosts`**: + ```bash + 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: +```bash +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: +```bash +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: +```bash +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: + ```bash + 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: + ```bash + sudo systemctl enable sshd + sudo systemctl start sshd + ``` + +2. **Set Up SSH Keys**: + - Generate an SSH key pair on your client machine: + ```bash + ssh-keygen -t rsa -b 4096 + ``` + - Copy the public key to your Arch Linux server: + ```bash + ssh-copy-id astronaut@your_server_ip + ``` + +#### Step 12: Exit Chroot and Reboot +Exit the chroot environment and reboot: +```bash +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: +```bash +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**: + ```bash + sudo pacman -S networkmanager + ``` + +2. **Enable NetworkManager**: + ```bash + 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: + ```bash + 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: ```bash