Ubuntu-Primary-Settings 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Ubuntu System Setup Guide
  2. ## 1. Update and Upgrade Ubuntu System
  3. To ensure your system is up to date, run the following commands:
  4. ```bash
  5. sudo apt update && sudo apt upgrade -y
  6. ```
  7. This will update the package list and upgrade all installed packages.
  8. ---
  9. ## 2. Create a New Sudo User
  10. Creating a new sudo user helps maintain security instead of using the root account.
  11. ### **Step 1: Add a New User**
  12. Replace `username` with your desired username:
  13. ```bash
  14. sudo adduser username
  15. ```
  16. You will be prompted to enter a password and user details.
  17. ### **Step 2: Grant Sudo Privileges**
  18. ```bash
  19. sudo usermod -aG sudo username
  20. ```
  21. This adds the user to the `sudo` group, allowing administrative access.
  22. ### **Step 3: Verify the User Has Sudo Access**
  23. Switch to the new user:
  24. ```bash
  25. su - username
  26. ```
  27. Run a test command:
  28. ```bash
  29. sudo whoami
  30. ```
  31. If successful, it should return `root`.
  32. ---
  33. ## 3. Disable Root SSH Access
  34. To enhance security, disable SSH access for the root user.
  35. ### **Step 1: Edit the SSH Configuration File**
  36. ```bash
  37. sudo nano /etc/ssh/sshd_config
  38. ```
  39. ### **Step 2: Find and Modify the Following Line**
  40. Change:
  41. ```bash
  42. PermitRootLogin yes
  43. ```
  44. To:
  45. ```bash
  46. PermitRootLogin no
  47. ```
  48. ### **Step 3: Save and Exit**
  49. Press `CTRL+X`, then `Y`, and hit `ENTER` to save the file.
  50. ### **Step 4: Restart the SSH Service**
  51. ```bash
  52. sudo systemctl restart ssh
  53. ```
  54. ### **Step 5: Verify Root SSH is Disabled**
  55. Try logging in as root via SSH:
  56. ```bash
  57. ssh root@your-server-ip
  58. ```
  59. It should now be blocked.
  60. ---
  61. ## 4. Additional Security Measures
  62. - Use **SSH key authentication** instead of passwords.
  63. - Change the **default SSH port** to a non-standard port.
  64. - Use **firewalls** like `ufw` to allow only necessary connections.
  65. ---
  66. ## **Done! 🎉**
  67. Your Ubuntu system is now **updated, secure, and configured with a sudo user**.