{"id":259,"date":"2024-05-06T13:39:46","date_gmt":"2024-05-06T13:39:46","guid":{"rendered":"https:\/\/zalvis.com\/docs\/?p=259"},"modified":"2024-05-06T13:42:30","modified_gmt":"2024-05-06T13:42:30","slug":"how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac","status":"publish","type":"post","link":"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html","title":{"rendered":"How to Connect to a Remote Server via SSH from Windows, Linux and Mac"},"content":{"rendered":"<p>SSH (Secure Shell) is a cryptographic protocol for securely connecting to a remote server over an unsecured network. It is essential for managing remote systems, networking, and communicating with remote servers.<\/p>\n<p>The protocol provides a secure connection between a client and a server. It enables managing other computers, transferring files, and executing commands on a remote machine.<\/p>\n<p><strong>This guide explains how to SSH to a remote server from Windows, Linux, or Mac.<\/strong><\/p>\n<p class=\"h3\">Prerequisites<\/p>\n<ul>\n<li>The remote computer must be turned on and have a network connection.<\/li>\n<li>The IP address or the name of the remote machine.<\/li>\n<li>Permission to access the remote computer.<\/li>\n<li>Firewall settings to allow SSH connections.<\/li>\n<\/ul>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_81 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#What_Is_SSH\" >What Is SSH?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#How_Does_SSH_Work\" >How Does SSH Work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#How_to_Enable_an_SSH_Connection\" >How to Enable an SSH Connection<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Install_SSH_Component_on_Mac\" >Install SSH Component on Mac<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Install_SSH_Component_on_Linux\" >Install SSH Component on Linux<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Install_SSH_Component_on_Windows\" >Install SSH Component on Windows<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#How_to_Connect_via_SSH\" >How to Connect via SSH<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#SSH_Further_Steps\" >SSH Further Steps<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Change_the_Default_TCP_Listening_Port\" >Change the Default TCP Listening Port<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Use_SSH_Key_Pairs_for_Authentication\" >Use SSH Key Pairs for Authentication<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Disable_Password-Based_Logins_on_Your_Server\" >Disable Password-Based Logins on Your Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Disable_Root_Access\" >Disable Root Access<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Use_TCP_Wrappers\" >Use TCP Wrappers<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Secure_Login_Information_and_Employ_Multilayer_Security\" >Secure Login Information and Employ Multilayer Security<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#VNC_Over_SSH\" >VNC Over SSH<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/zalvis.com\/docs\/how-to-connect-to-a-remote-server-via-ssh-from-windows-linux-and-mac.html\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 id=\"ftoc-heading-1\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"What_Is_SSH\"><\/span>What Is SSH?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><strong>Secure Shell<\/strong>, sometimes called <strong>Secure Socket Shell<\/strong>, is a protocol that allows you to securely connect to a remote computer\u00a0a server using a text-based interface.<\/p>\n<p>When a secure SSH connection is established, a shell session starts. It enables manipulating the server by typing commands within the client on your local computer.<\/p>\n<p>System and network administrators use this protocol to manage remote servers and machines. Anyone who requires managing a computer remotely in a highly secure manner uses SSH.<\/p>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\">\n<h2 id=\"ftoc-heading-2\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"How_Does_SSH_Work\"><\/span>How Does SSH Work?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Both the client and server participate in establishing a secure SSH communication channel. Creating an SSH connection relies on the following components and steps:<\/p>\n<ul>\n<li><strong>Client-side component<\/strong>. A client-side component is an application or program used\u00a0to connect to another machine. The client uses remote host information to initiate the connection through the program. If the credentials are verified, the program establishes an encrypted connection.<\/li>\n<li><strong>Server-side component<\/strong>. On the server&#8217;s side, an SSH daemon constantly listens to a specific TCP\/IP port (the default SSH port number is 22) for possible client connection requests. Once a client initiates a connection through the defined port, the SSH daemon responds with the software and the protocol versions it supports. The default protocol version for SSH communication is version 2.<\/li>\n<li><strong>Key exchange<\/strong>. The client and server exchange cryptographic keys to create a secure communication channel. The keys help encrypt subsequent communication.<\/li>\n<li><strong>Authentication<\/strong>. When establishing a connection, the client provides identification data to the server (as a username\/password or SSH keys). If the provided credentials are correct, SSH creates a new encrypted communication session.<\/li>\n<\/ul>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\">\n<h2 id=\"ftoc-heading-3\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"How_to_Enable_an_SSH_Connection\"><\/span>How to Enable an SSH Connection<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Since creating an SSH connection requires both a client and a server component, ensure they are installed on the local and remote servers. The sections below demonstrate how to install a client-side and server-side component depending on the OS.<\/p>\n<h3 id=\"ftoc-heading-4\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Install_SSH_Component_on_Mac\"><\/span>Install SSH Component on Mac<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>macOS typically has the SSH client preinstalled. Open the terminal and check with the following command:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>ssh -v<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-262\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7923.png\" alt=\"Install SSH Component on Mac\" width=\"800\" height=\"178\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7923.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7923-300x67.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7923-768x171.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>The command shows the installed SSH version. To use a third-party SSH application, such as OpenSSH, use the following Homebrew command:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>brew install openssh<\/code><\/pre>\n<p>The installation allows managing a separate version from the system&#8217;s default SSH component. Alternatively, install PuTTY on macOS to use a GUI-based SSH client.<\/p>\n<p>To enable SSH server remote login on a macOS, do the following:<\/p>\n<p>1. Go to <strong>System Settings<\/strong>.<\/p>\n<p>2. Click <strong>General<\/strong> in the left menu.<\/p>\n<p>3. Locate and open <strong>Sharing<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-263\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7924.png\" alt=\"Install SSH Component on Mac\" width=\"800\" height=\"400\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7924.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7924-300x150.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7924-768x384.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/>4. Enable <strong>Remote Login<\/strong> to allow SSH access to the device.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-264\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7925.png\" alt=\"Install SSH Component on Mac\" width=\"800\" height=\"350\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7925.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7925-300x131.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7925-768x336.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<h3 id=\"ftoc-heading-5\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Install_SSH_Component_on_Linux\"><\/span>Install SSH Component on Linux<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Some Linux distributions do not have an SSH component installed by default. Typical solutions are installing OpenSSH or a GUI solution, such as the PuTTY client for Ubuntu.<\/p>\n<p>Installing OpenSSH requires access to the terminal on the server and the computer you use for connecting. The steps for installing and setting up the OpenSSH client and server component are below:<\/p>\n<p>1. To install the client component, run one of the following commands on the client machine:<\/p>\n<p><strong>For Debian\/Ubuntu-based Systems:<\/strong><\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo apt install openssh-client<\/code><\/pre>\n<p><strong>For Red Hat-based systems (such as CentOS or Fedora):<\/strong><\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo dnf install openssh-clients<\/code><\/pre>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo yum install openssh-clients<\/code><\/pre>\n<p>2. Next, install the server component on the server machine:<\/p>\n<p><strong>For Debian\/Ubuntu-based Systems:<\/strong><\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo apt install openssh-server<\/code><\/pre>\n<p><strong>For Red Hat-based systems (such as CentOS or Fedora):<\/strong><\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo dnf install openssh-server<\/code><\/pre>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo yum install openssh-server<\/code><\/pre>\n<p>3. After installing the components, the SSH service automatically starts. View the service status with:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>systemctl status sshd<\/code><\/pre>\n<p>In case the service is not running, run it with the following command:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo systemctl start sshd<\/code><\/pre>\n<p>The command does not print an output.<\/p>\n<p>4. To have the service start automatically on boot, run:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sudo systemctl enable sshd<\/code><\/pre>\n<p>Enabling the <strong>sshd <\/strong>service starts it during the boot process.<\/p>\n<h3 id=\"ftoc-heading-6\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Install_SSH_Component_on_Windows\"><\/span>Install SSH Component on Windows<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>SSH is not a default component on Windows systems. Windows 10 and later versions include a native OpenSSH app.<\/p>\n<p>To enable SSH, do the following:<\/p>\n<p>1. Open <strong>Settings<\/strong> -&gt; <strong>Apps &amp; features<\/strong> -&gt; <strong>Optional features<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-266\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7926.png\" alt=\"Install SSH Component on Windows\" width=\"800\" height=\"330\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7926.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7926-300x124.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7926-768x317.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>2. Click the <strong>Add a feature<\/strong> button.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-267\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7927.png\" alt=\"Install SSH Component on Windows\" width=\"800\" height=\"360\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7927.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7927-300x135.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7927-768x346.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>3. Search for and install the <strong>OpenSSH<\/strong> app.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-268\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7928.png\" alt=\"Install SSH Component on Windows\" width=\"399\" height=\"400\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7928.png 399w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7928-300x300.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7928-150x150.png 150w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/><\/p>\n<p>Alternatively, a popular option is to install PuTTY on Windows or to use a Linux distribution through the WSL (Windows Subsystem for Linux) feature.<\/p>\n<h2 id=\"ftoc-heading-7\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"How_to_Connect_via_SSH\"><\/span>How to Connect via SSH<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>After installing and setting up the SSH client and server on each machine, you can establish a secure remote connection. To connect to a server, do the following:<\/p>\n<p>1. Open the command line\/terminal window and run the following ssh command:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>ssh [username]@[host_ip_address]<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<p>Provide the username and host IP address. If the username is the same as the local machine, omit the username from the command. To test if SSH is installed correctly, try creating an SSH connection to <em>localhost<\/em>.<\/p>\n<p>2. When connecting to the server for the first time, a message appears asking to confirm the connection. Type <strong>yes<\/strong> and press <strong>Enter<\/strong> to confirm the remote server identification on the local machine.<\/p>\n<p>3. Provide the password when prompted and press <strong>Enter<\/strong>. The screen does not display characters as you are typing.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-269\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7929.jpeg\" alt=\"How to Connect via SSH\" width=\"800\" height=\"390\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7929.jpeg 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7929-300x146.jpeg 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7929-768x374.jpeg 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>A digital signature ECDSA key fingerprint helps authenticate the machine and establishes a connection to the remote server.<\/p>\n<p>If the computer you are trying to connect to is on the same network, then it is best to use a private IP address instead of a public IP address.<\/p>\n<div class=\"notice-note\">\n<div class=\"note-icon-wrapper\">\n<p>Additionally, ensure the correct TCP port listens for connection requests and that port forwarding settings are correct. The default port number is <strong>22<\/strong> unless the configuration has been changed. You may also append the port number after the host IP address.<\/p>\n<p>When using a port number, the following two examples are valid:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>ssh [username]@[host_ip_address]:[port]<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<pre class=\"wp-block-code copy-the-code-target\"><code>ssh [username]@[host_ip_address] -p [port]<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/pre>\n<p>If there are any issues connecting to the remote server, make sure that:<\/p>\n<ul>\n<li>The IP address of the remote machine is correct.<\/li>\n<li>The port the SSH daemon is listening to is not blocked by a firewall or forwarded incorrectly.<\/li>\n<li>The username and password are correct.<\/li>\n<li>The SSH software is installed correctly.<\/li>\n<\/ul>\n<h2 id=\"ftoc-heading-8\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"SSH_Further_Steps\"><\/span>SSH Further Steps<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>After establishing a connection to your server using SSH, there are additional steps to improve SSH security. Default values should always be changed; not changing them leaves a server vulnerable to attacks. Some of the suggestions require editing the SSH configuration file.<\/p>\n<p>Below is a list of practical steps to secure the SSH connection:<\/p>\n<h3 id=\"ftoc-heading-9\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Change_the_Default_TCP_Listening_Port\"><\/span>Change the Default TCP Listening Port<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Instead of using the default port 22, try a higher number. Avoid using a port number that is easy to guess, such as 222, 2222, or 22222.<\/p>\n<h3 id=\"ftoc-heading-10\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Use_SSH_Key_Pairs_for_Authentication\"><\/span>Use SSH Key Pairs for Authentication<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Passwordless SSH login is safer and allows logging in without using an SSH key pair (which is faster and more convenient).<\/p>\n<h3 id=\"ftoc-heading-11\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Disable_Password-Based_Logins_on_Your_Server\"><\/span>Disable Password-Based Logins on Your Server<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If your password gets cracked, this will eliminate the possibility of using it to log into your servers. Before you turn off the option to log in using passwords, ensure that authentication using key pairs works.<\/p>\n<h3 id=\"ftoc-heading-12\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Disable_Root_Access\"><\/span>Disable Root Access<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Removing default root access to your server makes accessing the root account harder for unwanted solicitors. Instead, use a regular account with the su &#8211; command to switch to a root user.<\/p>\n<h3 id=\"ftoc-heading-13\" class=\"wp-block-heading ftwp-heading\"><span class=\"ez-toc-section\" id=\"Use_TCP_Wrappers\"><\/span>Use TCP Wrappers<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>TCP wrappers enable restricting access to specific IP addresses or hostnames. Configure which host can connect by editing the <em>\/etc\/hosts.allow<\/em> and<em>\/etc\/hosts.deny<\/em> files. Note that the first file has higher authorization than the second.<\/p>\n<p>For example, to allow SSH access to a single host, first deny all hosts by adding these two lines in the <em>\/etc\/hosts.deny<\/em> file:<\/p>\n<pre class=\"wp-block-code copy-the-code-target\"><code>sshd : ALL\r\nALL : ALL<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-270\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7930.png\" alt=\"Use TCP Wrappers\" width=\"800\" height=\"370\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7930.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7930-300x139.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7930-768x355.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><span style=\"font-family: Consolas, Monaco, monospace; color: #333333; background-color: #ffffff;\"><br \/>\nThen, in the <\/span><em style=\"font-family: Consolas, Monaco, monospace; color: #333333;\">\/etc\/hosts.allow<\/em><span style=\"font-family: Consolas, Monaco, monospace; color: #333333; background-color: #ffffff;\"> file, add a line with the allowed hosts for the SSH service:<br \/>\nsshd : 10.10.0.5, LOCAL<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-271\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7931.png\" alt=\"Use TCP Wrappers\" width=\"800\" height=\"230\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7931.png 800w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7931-300x86.png 300w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7931-768x221.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><br \/>\nThe host can be an IP address, an IP range, or a hostname.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Secure_Login_Information_and_Employ_Multilayer_Security\"><\/span>Secure Login Information and Employ Multilayer Security<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><span style=\"font-size: 16px;\">Use different methods to limit SSH access to your servers, or use services that block anyone using <\/span>brute force<span style=\"font-size: 16px;\"> to gain access. <\/span>Fail2ban<span style=\"font-size: 16px;\"> is one example of such a service.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"VNC_Over_SSH\"><\/span>VNC Over SSH<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-size: 16px;\">In a Virtual Network Computing (VNC) environment, it is possible to encrypt connections using SSH <\/span>tunneling<span style=\"font-size: 16px;\"> via the <\/span><strong style=\"font-size: 16px;\"><code>ssh<\/code><\/strong><span style=\"font-size: 16px;\"> command and through PuTTY.<\/span><\/p>\n<p><span style=\"font-size: 16px;\"><br \/>\n<\/span>To tunnel VNC connections over SSH, run the following command in the command line\/terminal:<\/p>\n<p><code>ssh -L [local_address]:[local_port]:[VNC_server_address]:[VNC_server_port] -N -f -l [username] [hostname_or_IP]<\/code><button class=\"copy-the-code-button\" title=\"Copy to Clipboard\" data-style=\"svg-icon\"><\/button><\/p>\n<p>The command does the following:<\/p>\n<ul>\n<li><strong><code>ssh<\/code><\/strong>. Starts the SSH client program on your local machine and enables secure connection to the SSH server on a remote computer.<\/li>\n<li><strong><code>-L [local_address]:[local_port]:[VNC_server_address]:[VNC_server_port]<\/code><\/strong>. The local address and port for the client on the local machine are to be forwarded to the specified server host and port of the remote machine.<\/li>\n<li><strong><code>-N<\/code><\/strong>. Forwards ports without executing a remote command.<\/li>\n<li><strong><code>-f<\/code><\/strong>. Sends SSH to the background after the password is provided. This allows typing commands in the local terminal.<\/li>\n<li><strong><code>-l [username]<\/code><\/strong>. The username for connecting to the SSH server.<\/li>\n<li><strong><code>[hostname_or_IP]<\/code><\/strong>. The hostname or IP of the SSH server.<\/li>\n<\/ul>\n<p>You can also connect to a remote server via SSH tunnel using PuTTY. In the PuTTY configuration window, do the following:<\/p>\n<p>1. Go to <strong>Connection<\/strong> -&gt; <strong>SSH<\/strong> -&gt; <strong>Tunnels.<\/strong><\/p>\n<p>2. Type in the source port number in the <strong>Source port<\/strong> field.<\/p>\n<p>3. Type the VNC server address and port in the <strong>Destination field<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-272\" src=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7932.png\" alt=\"VNC Over SSH\" width=\"575\" height=\"552\" srcset=\"https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7932.png 575w, https:\/\/zalvis.com\/docs\/wp-content\/uploads\/2024\/05\/IMG_7932-300x288.png 300w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/p>\n<p>4. Start the SSH session as you normally would.<\/p>\n<p>5. Connect to your server with a VNC client of your choice.<\/p>\n<h2 class=\"h3\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You should now be able to connect to a remote server with SSH<strong>. <\/strong>There are many other methods to establish a connection between two remote computers, but the ones covered here are most common and secure.<\/p>\n<p>Next, see how to mount a remote file system using SSH with the SSHFS client.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"jvgrx69f32e2892faf\" >If you enjoyed this article, then you\u2019ll love Zalvis's Cloud Hosting platform. Turbocharge your website and get 24\/7 support from our veteran team. Our world-class hosting infrastructure focuses on auto-scaling, performance, and security. Let us show you the Zalvis difference! <a href=\"https:\/\/zalvis.com\/\">Check out our services.<\/a><\/div><style type=\"text\/css\">\r\n@media screen and (min-width: 1201px) {\r\n.jvgrx69f32e2892faf {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 993px) and (max-width: 1200px) {\r\n.jvgrx69f32e2892faf {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 769px) and (max-width: 992px) {\r\n.jvgrx69f32e2892faf {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (min-width: 768px) and (max-width: 768px) {\r\n.jvgrx69f32e2892faf {\r\ndisplay: block;\r\n}\r\n}\r\n@media screen and (max-width: 767px) {\r\n.jvgrx69f32e2892faf {\r\ndisplay: block;\r\n}\r\n}\r\n<\/style>\r\n","protected":false},"excerpt":{"rendered":"<p>SSH (Secure Shell) is a cryptographic protocol for securely connecting to a remote server over an unsecured network. It is essential for managing remote systems, networking, and communicating with remote servers. The protocol provides a secure connection between a client and a server. It enables managing other computers, transferring files, and executing commands on a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-259","post","type-post","status-publish","format-standard","hentry","category-getting-started"],"_links":{"self":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/comments?post=259"}],"version-history":[{"count":6,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/259\/revisions"}],"predecessor-version":[{"id":275,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/posts\/259\/revisions\/275"}],"wp:attachment":[{"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/media?parent=259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/categories?post=259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zalvis.com\/docs\/wp-json\/wp\/v2\/tags?post=259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}