{"id":26237,"date":"2024-05-03T04:52:36","date_gmt":"2024-05-03T04:52:36","guid":{"rendered":"https:\/\/linuxways.net\/?p=26237"},"modified":"2024-05-03T04:52:36","modified_gmt":"2024-05-03T04:52:36","slug":"enable-openssh-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/enable-openssh-on-ubuntu-24-04\/","title":{"rendered":"How To Enable OpenSSH on Ubuntu 24.04"},"content":{"rendered":"<p>OpenSSH or open secure shell protocol provides secure communication channels while communicating over potentially insecure networks. OpenSSH represents the practical implementation of the SSH protocol, relying on both the client and server components.<\/p>\n<p>The primary use for OpenSSH on Linux-based operating systems is to access the command line interface remotely of the client machine. By doing this, you can execute various commands and transfer data as well. To use this protocol on Ubuntu 24.04 not only do you have to install it first but also have to enable it and this guide is about enabling the OpenSSH service.<\/p>\n<p><strong>Outline:<\/strong><\/p>\n<ul>\n<li><a href=\"#post-26237-_ncbe3y8nqdn4\">How To Enable OpenSSH on Ubuntu 24.04<\/a><\/li>\n<li><a href=\"#post-26237-_6t9h1a4r8exl\">Accessing Ubuntu 24.04 Through OpenSSH<\/a><\/li>\n<li><a href=\"#post-26237-_qt7i0mqz5pgy\">Accessing a System From Ubuntu 24.04 via OpenSSH<\/a><\/li>\n<li><a href=\"#post-26237-_kx9m16ioq4z2\">Setting up a Custom Port for SSH on Ubuntu 24.04<\/a><\/li>\n<li><a href=\"#post-26237-_yfl7zbyfcmt5\">Conclusion<\/a><\/li>\n<\/ul>\n<h2><a id=\"post-26237-_ncbe3y8nqdn4\"><\/a>How To Enable OpenSSH on Ubuntu 24.04<\/h2>\n<p>The OpenSSH still stands out over other communication mediums as it comes with strong encryption algorithms which are difficult to crack. It uses public-key cryptography for authentication including support for a wide range of key types, thus providing better security and performance. On Ubuntu 24.04 it doesn\u2019t come preinstalled so you have to install it via apt:<\/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><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"319\" class=\"wp-image-26254\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-1.png 805w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-1-300x119.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-1-768x304.png 768w\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" \/><\/p>\n<p>Installing the OpenSSH server automatically installs the client as well but if you need your system for only accessing other systems then you can install only the client and for that execute:<\/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-client<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"226\" class=\"wp-image-26261\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-2.png 727w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-2-300x93.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/p>\n<p>After the installation is complete now enable the SSH service on Ubuntu:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl <span class=\"kw3\">enable<\/span> <span class=\"re5\">--now<\/span> <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"247\" class=\"wp-image-26267\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-3.png 725w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-3-300x102.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><\/p>\n<p>After enabling the service verify its status through the <em>systemctl <\/em>utility:<\/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><img loading=\"lazy\" decoding=\"async\" width=\"729\" height=\"277\" class=\"wp-image-26273\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-4.png 729w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-4-300x114.png 300w\" sizes=\"auto, (max-width: 729px) 100vw, 729px\" \/><\/p>\n<p>If by any means the service is still not active then try starting it, usually the ssh service automatically starts upon enabling it:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl start <span class=\"kw2\">ssh<\/span><\/div><\/div>\n<p>To ensure the proper functioning of SSH service it has to be allowed via a firewall as it might block the communications except port 22:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow sshd<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"722\" height=\"171\" class=\"wp-image-26278\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-5.png 722w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-5-300x71.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<p>Once the rules are added verify them by checking the status of the firewall and afterward reload the firewall to apply the changes:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw status<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"726\" height=\"241\" class=\"wp-image-26286\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-6.png 726w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-6-300x100.png 300w\" sizes=\"auto, (max-width: 726px) 100vw, 726px\" \/><\/p>\n<h2><a id=\"post-26237-_6t9h1a4r8exl\"><\/a>Accessing Ubuntu 24.04 Through OpenSSH<\/h2>\n<p>The OpenSSH is now enabled and you can access your Ubuntu 24.04 on any other system. For that first find out the IP address of your system:<\/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><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"360\" class=\"wp-image-26292\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-7.png 728w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-7-300x148.png 300w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/p>\n<p>Now just use the SSH command sling with the username and the IP address of your system on the host system:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">ssh<\/span> USERNAME<span class=\"sy0\">@<\/span>IP_ADDRESS<\/div><\/div>\n<p>Here, I have accessed Ubuntu 24.04 on Debian 12 through SSH protocol. On the first login, the system will ask for confirmation to proceed, enter yes:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"636\" height=\"313\" class=\"wp-image-26300\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-8.png 636w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-8-300x148.png 300w\" sizes=\"auto, (max-width: 636px) 100vw, 636px\" \/><\/p>\n<p>Now if you want to exit the remote device then execute:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw3\">exit<\/span><\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"414\" class=\"wp-image-26308\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-9.png 638w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-9-300x195.png 300w\" sizes=\"auto, (max-width: 638px) 100vw, 638px\" \/><\/p>\n<h2><a id=\"post-26237-_qt7i0mqz5pgy\"><\/a>Accessing a System From Ubuntu 24.04 via OpenSSH<\/h2>\n<p>In the below image, I have accessed Debian 12 from Ubuntu 24.04 using the same command used for accessing Ubuntu 24.04 from Debian 12:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"515\" class=\"wp-image-26324\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-10.png 800w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-10-300x193.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-10-768x494.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h2><a id=\"post-26237-_kx9m16ioq4z2\"><\/a>Setting up a Custom Port for SSH on Ubuntu 24.04<\/h2>\n<p>By default, the SSH service uses port 22 for communication which makes the network vulnerable to cyberattacks and sometimes it can cause port conflicts in case you are using NAT configuration for multiple servers. To change the port for SSH open the SSHd_config file in any editor:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">nano<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>ssh<span class=\"sy0\">\/<\/span>sshd_config<\/div><\/div>\n<p>Here you can set the port number from 1024 to 65535, the reason behind keeping the number in this range is to strike a balance between avoiding reserved ports and minimizing the risk of collisions. Here, I have selected port number 1046:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"420\" class=\"wp-image-26344\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-11.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-11.png 667w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-11-300x189.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/p>\n<p>Now restart the SSH service to apply the port changes:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> systemctl restart sshd<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"155\" class=\"wp-image-26352\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-12.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-12.png 663w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-12-300x70.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/p>\n<p>To enable SSH communication over the new port, you have to allow it through the firewall and for that execute:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw allow <span class=\"nu0\">1046<\/span><span class=\"sy0\">\/<\/span>tcp<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"665\" height=\"161\" class=\"wp-image-26360\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-13.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-13.png 665w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-13-300x73.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/p>\n<p>Now verify the rules added for the new port and then reload the firewall:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> ufw status<br \/>\n<br \/>\n<span class=\"kw2\">sudo<\/span> ufw reload<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"317\" class=\"wp-image-26367\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-14.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-14.png 667w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-14-300x143.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/p>\n<p>Now use the set port to access the server from Ubuntu by executing:<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"width:100%;\"><div class=\"bash codecolorer\"><span class=\"kw2\">sudo<\/span> <span class=\"kw2\">ssh<\/span> <span class=\"re5\">-p<\/span> <span class=\"nu0\">1046<\/span> USERNAME<span class=\"sy0\">@<\/span>IP_ADDRESS<\/div><\/div>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"805\" height=\"477\" class=\"wp-image-26385\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-15.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-15.png 805w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-15-300x178.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2024\/05\/word-image-26237-15-768x455.png 768w\" sizes=\"auto, (max-width: 805px) 100vw, 805px\" \/><\/p>\n<p><strong>Note: <\/strong>The SSH is a client-side tool that is used for system administration file transfers and communication across untrusted networks. Whereas sshd is the server-side daemon that listens to incoming connections via SSH protocol. It handles user authentication, encryption terminal connections, and tunneling.<\/p>\n<h2><a id=\"post-26237-_yfl7zbyfcmt5\"><\/a>Conclusion<\/h2>\n<p>To enable OpenSSH on Ubuntu 24.04 you first need to install it via its default package installer and then enable it through <em>systemctl<\/em> command. By default, it uses port 22 which can be changed to a custom port number ranging from 1024 to 65535. Further, to access any system from Ubuntu 24.04 use the server IP address, its username along with the ssh command.<\/p>","protected":false},"excerpt":{"rendered":"<p>To enable OpenSSH on Ubuntu 24.04 you first need to install it via its default package installer and then enable it through systemctl command.<\/p>","protected":false},"author":113,"featured_media":26529,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-26237","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\/26237","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\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=26237"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/26237\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/26529"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=26237"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=26237"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=26237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}