{"id":38589,"date":"2022-04-10T15:35:08","date_gmt":"2022-04-10T15:35:08","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=38589"},"modified":"2023-11-30T05:34:05","modified_gmt":"2023-11-30T05:34:05","slug":"enable-ssh-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2022\/04\/enable-ssh-ubuntu-22-04\/","title":{"rendered":"How to Enable SSH Service in Ubuntu 22.04 LTS"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-38590\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/ssh-putty-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/p>\n<p>This simple tutorial shows how to enable Secure Shell (SSH) in Ubuntu 22.04, so you can login remotely and transfer data securely via the cryptographic network protocol.<\/p>\n<p>Ubuntu uses OpenSSH to provide Secure Shell services. The client is pre-installed with out-of-the-box support for connecting to remove SSH server. The server package is available in system repository but not installed by default.<\/p>\n<h3>1. Install SSH Server:<\/h3>\n<p>Firstly, connect to your Ubuntu server, or press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal in Ubuntu desktop.<\/p>\n<p>When it opens, run the command below to install the server package:<\/p>\n<pre>sudo apt install ssh<\/pre>\n<p><i>Type user password for sudo authentication, though there&#8217;s no asterisk feedback<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-ssh.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38592\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-ssh-600x301.webp\" alt=\"\" width=\"600\" height=\"301\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-ssh-600x301.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-ssh-300x150.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-ssh.webp 750w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Once installed the service should run automatically. If not, use commands below to enable and start it:<\/p>\n<pre>sudo systemctl enable sshd &amp;&amp; sudo systemctl start ssh<\/pre>\n<p>And, check the service status using command:<\/p>\n<pre>systemctl status ssh.service<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38593\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status-600x398.webp\" alt=\"\" width=\"600\" height=\"398\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status-600x398.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status-300x199.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status-768x509.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/sshd-status.webp 777w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<h3>2. Configure SSH Server:<\/h3>\n<p>After step 1, you should be able to connect to this Ubuntu server or desktop remotely via <code>ssh<\/code> and\/or <code>scp<\/code> commands.<\/p>\n<p>You may however configure it to listen on a different port, specify which users allowed to login, change the authentication methods, etc.<\/p>\n<p>To do so, edit the &#8220;<i>\/etc\/ssh\/sshd_config<\/i>&#8221; via the command below:<\/p>\n<pre>sudo nano \/etc\/ssh\/sshd_config<\/pre>\n<p><i>For Ubuntu Desktop, replace <code>nano<\/code> with <code>gedit<\/code> to edit the config file with a graphical interface.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-38594\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd-600x425.jpg\" alt=\"\" width=\"600\" height=\"425\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd-600x425.jpg 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd-300x213.jpg 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd-768x544.jpg 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/config-sshd.jpg 1017w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>When the file opens, by removing &#8216;<b>#<\/b>&#8216; at the beginning and changing the number after &#8216;Port&#8217; will change the listening port; Enable &#8220;PermitRootLogin prohibit-password&#8221; (remove # at the beginning will enable it) will allow root login via authentication key. To allow password login, change the value to &#8216;yes&#8217;, and you need to enable &#8220;PasswordAuthentication yes&#8221;.<\/p>\n<p>For more configurations, see <a href=\"https:\/\/www.ssh.com\/academy\/ssh\/sshd_config\" target=\"_blank\" rel=\"noopener\">this document<\/a>. And, if you want to setup an authentication key to login without password, try <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2021\/10\/ssh-key-without-password-ubuntu\/\" target=\"_blank\" rel=\"noopener\">this tutorial<\/a>.<\/p>\n<p>After saving the file, remember to <b>restart the SSH service to apply changes<\/b>:<\/p>\n<pre>sudo systemctl restart sshd<\/pre>\n<h3>3. Login or transfer data via SSH:<\/h3>\n<p>After setup the remote SSH server, you may run the command below to login remotely:<\/p>\n<pre>ssh server_user@server_ip -p 22890<\/pre>\n<p>Change the port number 22890 to yours or skip the <code>-p<\/code> flag if the default port is in use.<\/p>\n<p>And, copy data from local to server via scp command:<\/p>\n<pre>scp -P 22890 \/PATH\/TO\/FILE server_user@server_ip:\/PATH\/TO\/DESTINATION<\/pre>\n<p>Or, grab data from server to local machine&#8217;s current directory via command:<\/p>\n<pre>scp -P 22890 server_user@server_ip:\/PATH\/TO\/FILE .\/<\/pre>","protected":false},"excerpt":{"rendered":"<p>This simple tutorial shows how to enable Secure Shell (SSH) in Ubuntu 22.04, so you can login remotely and transfer data securely via the cryptographic network protocol. Ubuntu uses OpenSSH to provide Secure Shell services. The client is pre-installed with out-of-the-box support for connecting to remove SSH server. The server package is available in system [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38590,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[24],"class_list":["post-38589","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-ssh"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/38589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=38589"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/38589\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/38590"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=38589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=38589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=38589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}