{"id":21363,"date":"2023-10-01T17:23:18","date_gmt":"2023-10-01T17:23:18","guid":{"rendered":"https:\/\/linuxways.net\/?p=21363"},"modified":"2023-10-01T17:23:18","modified_gmt":"2023-10-01T17:23:18","slug":"how-to-set-up-ssh-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-set-up-ssh-on-ubuntu-22-04\/","title":{"rendered":"How to Set Up SSH on Ubuntu 22.04?"},"content":{"rendered":"<p>SSH (Secure Socket Shell) is a client-server technology that allows system administrators to access an unsecured network in a secure way. SSH is a network protocol like HTTP that is used on top of the TCP\/IP layer and is part of the \u201c<strong>Application Layer<\/strong>\u201d. The SSH consists of a \u201c<strong>transport layer<\/strong>\u201d, a \u201c<strong>connection layer<\/strong>\u201d, and a \u201c<strong>user authentication layer<\/strong>\u201d. On Ubuntu, the OpenSSH Client runs on the TCP Port 22.<\/p>\n<p>This article explains the integration of SSH with Ubuntu 22.04.<\/p>\n<h2><strong>How to Set Up SSH on Ubuntu 22.04?<\/strong><\/h2>\n<p>To set up SSH on Ubuntu, follow the procedure below with each step explaining the commands in a simple way:<\/p>\n<h3><strong>Step 1: Update and Upgrade Ubuntu System<\/strong><\/h3>\n<p>Before installing SSH, make sure to update the repository first and then upgrade the packages. To update and upgrade use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt update<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"709\" height=\"464\" class=\"wp-image-21364\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-1.png 709w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-1-300x196.png 300w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/p>\n<p>To upgrade use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt upgrade<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"712\" height=\"712\" class=\"wp-image-21365\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-2.png 712w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-2-300x300.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-2-150x150.png 150w\" sizes=\"auto, (max-width: 712px) 100vw, 712px\" \/><\/p>\n<h3><strong>Step 2: Installing SSH<\/strong><\/h3>\n<p>To install SSH, use the command \u201c<strong>openssh-server<\/strong>\u201d with the apt install in the terminal.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> openssh-server <span class=\"re5\">-y<\/span><\/div><\/div>\n<p>It will take some time to install the necessary packages, wait for it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"671\" class=\"wp-image-21366\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-3.png 705w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-3-300x286.png 300w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/p>\n<h3><strong>Step 3: Checking the Status of the Server<\/strong><\/h3>\n<p>Once the installation of the SSH Server is completed, confirm by checking the status of the server. To check the status, use the following command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl status <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"747\" class=\"wp-image-21367\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-4.png 716w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-4-288x300.png 288w\" sizes=\"auto, (max-width: 716px) 100vw, 716px\" \/><\/strong><\/p>\n<h3><strong>Step 4: Allowing Connection<\/strong><\/h3>\n<p>As the SSH Server is running, now we need to allow the connection on the SSH Port. Use the command below:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p>This will allow the connection:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"62\" class=\"wp-image-21368\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-5.png 888w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-5-300x21.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-5-768x54.png 768w\" sizes=\"auto, (max-width: 888px) 100vw, 888px\" \/><\/p>\n<h3><strong>Step 5: Save the UFW Rules<\/strong><\/h3>\n<p>UFW or \u201cUncomplicated FireWall\u201d is a user-friendly tool used for managing \u201cip-tables\u201d and \u201cfirewall rules\u201d. Enable and reload the \u201cufw\u201d to save changes in \u201cufw\u201d using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw <span class=\"kw3\">enable<\/span> <span class=\"sy0\">&amp;&amp;<\/span> <span class=\"kw2\">sudo<\/span> ufw reload<\/div><\/div>\n<p>This will configure the Firewall:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"95\" class=\"wp-image-21369\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-6.png 766w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-6-300x37.png 300w\" sizes=\"auto, (max-width: 766px) 100vw, 766px\" \/><\/p>\n<h3><strong>Step 6: Connect the Client to the Host<\/strong><\/h3>\n<p>To connect another Linux System to the Host System using SSH ensure that \u201copenssh-server\u201d is installed and you use the correct IP Address and Hostname with the command<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ssh<\/span> <span class=\"sy0\">&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span><span class=\"kw2\">hostname<\/span><span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;&gt;@&lt;&lt;<\/span>strong<span class=\"sy0\">&gt;<\/span><span class=\"kw2\">ip<\/span><span class=\"sy0\">&lt;\/<\/span>strong<span class=\"sy0\">&gt;<\/span> address<span class=\"sy0\">&gt;<\/span><\/div><\/div>\n<p>In our case, our host has the IP of \u201c<strong>192.168.184.30<\/strong>\u201d and the hostname is \u201c<strong>tahakhan<\/strong>\u201d. To check the IP address of your Ubuntu system, use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ip<\/span> a<\/div><\/div>\n<p>This will display the IP Address of the Ubuntu system<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"724\" height=\"337\" class=\"wp-image-21370\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-7.png 724w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-7-300x140.png 300w\" sizes=\"auto, (max-width: 724px) 100vw, 724px\" \/><\/p>\n<p>Now, in the client or any other system, use the command below to connect to the host server.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ssh<\/span> tahakhan<span class=\"sy0\">@<\/span>192.168.184.130<\/div><\/div>\n<p>In our case, we have a Client System named \u201c<strong>ubuntu1<\/strong>\u201d and its IP is \u201c<strong>192.168.184.131<\/strong>\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"814\" height=\"400\" class=\"wp-image-21371\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-8.png 814w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-8-300x147.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-8-768x377.png 768w\" sizes=\"auto, (max-width: 814px) 100vw, 814px\" \/><\/p>\n<p>To connect the client \u201cubuntu1\u201d with server \u201ctahakhan\u201d, our command will be:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ssh<\/span> tahakhan<span class=\"sy0\">@<\/span>192.168.184.130<\/div><\/div>\n<p>It will ask for confirmation to continue the connection. Enter \u201c<strong>yes<\/strong>\u201d:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"170\" class=\"wp-image-21372\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-9.png 809w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-9-300x63.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-9-768x161.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/p>\n<p>Now it will ask for the server host(tahakhan) password for authentication:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"804\" height=\"414\" class=\"wp-image-21373\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-10.png 804w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-10-300x154.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-10-768x395.png 768w\" sizes=\"auto, (max-width: 804px) 100vw, 804px\" \/><\/p>\n<p>Enter the host system password. If the password is verified, you will see the Login status and you will now have access to the server system. <img loading=\"lazy\" decoding=\"async\" width=\"840\" height=\"55\" class=\"wp-image-21374\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-11.png 840w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-11-300x20.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-11-768x50.png 768w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/p>\n<p>Use the \u201cls\u201d command to list the host system files:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"279\" class=\"wp-image-21375\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-12.png 805w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-12-300x104.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-12-768x266.png 768w\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" \/><\/p>\n<p>Using this procedure, you can connect and access the host system.<\/p>\n<h3><strong>Step 7: Logout of the Server<\/strong><\/h3>\n<p>To logout the client (ubuntu1) from the server (tahakhan), use the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">exit<\/span><\/div><\/div>\n<p>This will log you out from the Server and Exit it. You will be back on your client system again:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"91\" class=\"wp-image-21376\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-13.png 808w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-13-300x34.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-13-768x86.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/p>\n<h3><strong>Step 8: Checking Login History (Optional)<\/strong><\/h3>\n<p>In the hosting system, you can also verify and check the recent login from clients using the command:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">grep<\/span> <span class=\"st0\">&quot;sshd&quot;<\/span> <span class=\"sy0\">\/<\/span>var<span class=\"sy0\">\/<\/span>log<span class=\"sy0\">\/<\/span>auth.log<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"289\" class=\"wp-image-21377\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-14.png 757w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-14-300x115.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<p>Check the recent history by scrolling down to the last info. Here you can see the recent connection by the client having an IP Address of \u201c192.168.184.131\u201d. This IP Address was of the client \u201cubuntu1\u201d.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"202\" class=\"wp-image-21378\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-15.png 757w, https:\/\/linuxways.net\/wp-content\/uploads\/2023\/09\/word-image-21363-15-300x80.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>To Set Up SSH on Ubuntu 22.04, first, use the \u201copenssh-server\u201d, update the rules, and configure the firewall to allow \u201cssh\u201d connections over a secure connection of the host with clients. SSH is used for secure connection to host servers and we can remotely access files and devices on the host system. This article explained how we can use the \u201copenssh-server\u201d, update the rules to allow \u201cssh\u201d connections, and then configure the firewall to allow a secure connection of the host with clients.<\/p>","protected":false},"excerpt":{"rendered":"<p>Use the \u201copenssh-server\u201d, update the rules, and configure the firewall to allow \u201cssh\u201d connections over a secure connection of the host with clients. <\/p>","protected":false},"author":110,"featured_media":22468,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-21363","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=21363"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/21363\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/22468"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=21363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=21363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=21363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}