{"id":16400,"date":"2023-10-10T07:35:50","date_gmt":"2023-10-10T07:35:50","guid":{"rendered":"https:\/\/cloudpap.com\/?post_type=docs&#038;p=16400"},"modified":"2023-10-10T07:35:51","modified_gmt":"2023-10-10T07:35:51","password":"","slug":"initial-server-setup-with-ubuntu-22-04","status":"publish","type":"docs","link":"https:\/\/cloudpap.com\/blog\/docs\/initial-server-setup-with-ubuntu-22-04\/","title":{"rendered":"Initial Server Setup with Ubuntu 22.04"},"content":{"rendered":"\n<p>Setting up a new server is a crucial step in ensuring the security and functionality of your system. Ubuntu 22.04 is the latest long-term support (LTS) release from Canonical, and it comes with a variety of features and improvements. In this guide, we will walk you through the essential steps of the initial server setup on Ubuntu 22.04.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disable Root Access<\/h2>\n\n\n\n<p>One of the first steps in securing your server is to disable root access. The root user has superuser privileges, and allowing direct access to it can pose a significant security risk. To disable root access, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Log in as a user with sudo privileges<\/strong>: First, log in to your server as a user with sudo privileges. If you don&#8217;t have a user with sudo access yet, you can create one (as explained in the next section).<\/li>\n\n\n\n<li><strong>Edit the SSH configuration file<\/strong>: Open the SSH configuration file using a text editor like Vim or Nano. For example:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo nano \/etc\/ssh\/sshd_config<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>Disable root login<\/strong>: Find the line that says <code>PermitRootLogin yes<\/code> and change it to <code>PermitRootLogin no<\/code>. This will prevent the root user from logging in directly.<\/li>\n\n\n\n<li><strong>Save and exit<\/strong>: Save the changes and exit the text editor.<\/li>\n\n\n\n<li><strong>Restart SSH service<\/strong>: To apply the changes, restart the SSH service:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo systemctl restart sshd<\/code><\/pre>\n\n\n\n<p>Root access is now disabled, and you should use a regular user account with sudo privileges for all administrative tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a Regular User Account<\/h2>\n\n\n\n<p>Creating a regular user account is essential for maintaining security and managing your server efficiently. To create a new user with sudo privileges, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create a new user<\/strong>: Replace <code>&lt;username&gt;<\/code> with your desired username:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo adduser &lt;username&gt;<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Set a password for the user<\/strong>: You&#8217;ll be prompted to set a password for the new user.<\/li>\n\n\n\n<li><strong>Grant sudo privileges<\/strong>: To give the new user administrative privileges, add them to the sudo group:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo usermod -aG sudo &lt;username&gt;<\/code><\/pre>\n\n\n\n<p>You now have a new user account with sudo privileges that can be used for server administration tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install Utilities: Vim and Screen<\/h2>\n\n\n\n<p>While Ubuntu comes with a range of pre-installed tools, you may want to install additional utilities to improve your server&#8217;s functionality and ease of use. Two commonly used utilities are Vim (a text editor) and Screen (a terminal multiplexer). You can install them with the following commands:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Vim<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo apt update\n   sudo apt install vim<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Install Screen<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo apt update\n   sudo apt install screen<\/code><\/pre>\n\n\n\n<p>With Vim, you have a powerful text editor at your disposal, and Screen allows you to create and manage multiple terminal sessions, which is especially handy when working remotely.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install a Firewall<\/h2>\n\n\n\n<p>Firewalls are crucial for server security as they control incoming and outgoing network traffic. Ubuntu 22.04 uses <code>ufw<\/code> (Uncomplicated Firewall) by default, which simplifies firewall management. To install and configure <code>ufw<\/code>, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install ufw<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo apt update\n   sudo apt install ufw<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li><strong>Enable ufw<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo ufw enable<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>Allow essential services<\/strong>:<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allow SSH for remote access: <code>sudo ufw allow OpenSSH<\/code><\/li>\n\n\n\n<li>If your server hosts other services (e.g., web server), allow those ports as needed.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li><strong>Enable ufw<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>   sudo ufw enable<\/code><\/pre>\n\n\n\n<p>Your firewall is now active and configured to allow essential traffic while blocking unauthorized access. Remember to adjust the rules as necessary to match your specific server setup.<\/p>\n\n\n\n<p>In conclusion, setting up a new server with Ubuntu 22.04 involves several crucial steps, including disabling root access, creating a regular user account with sudo privileges, installing essential utilities like Vim and Screen, and configuring a firewall to enhance security. Following these steps will help you establish a secure and functional server environment for your needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up a new server is a crucial step in ensuring the security and functionality of your system. Ubuntu 22.04 is the latest long-term support (LTS) release from Canonical, and it comes with a variety of features and improvements. In this guide, we will walk you through the essential steps of the initial server setup&#8230;<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"doc_category":[],"doc_tag":[],"class_list":["post-16400","docs","type-docs","status-publish","hentry"],"year_month":"2026-05","word_count":606,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Wallace","author_nicename":"wallace","author_url":"https:\/\/cloudpap.com\/blog\/author\/wallace\/"},"doc_category_info":[],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs\/16400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/comments?post=16400"}],"version-history":[{"count":0,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/docs\/16400\/revisions"}],"wp:attachment":[{"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/media?parent=16400"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/doc_category?post=16400"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/cloudpap.com\/blog\/wp-json\/wp\/v2\/doc_tag?post=16400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}