This guide offers detailed instructions for securely connecting to a Linux server via SSH from Windows, Linux, and macOS while ensuring secure remote access.
SSH (Secure Shell) is a widely used protocol for securely connecting to a remote Linux server from any operating system, including Windows, Linux, or macOS. This guide walks you through the steps for connecting via SSH from different platforms.
Key Points to Consider:
- This guide covers SSH connections from all major operating systems (Windows, Linux, macOS).
- Ensure you have the correct credentials (username, password) and the necessary privileges to access the server.
- If your server uses a non-standard SSH port, you will need to specify it with the -p option in your SSH command.
Step-by-step Instructions
Connecting to a Linux server from Linux or macOS
- Open the Terminal:
- For Linux: Press
Ctrl + Alt + T
or search for "Terminal" in your applications menu. - For macOS: Open Spotlight (
Command + Space
), type "Terminal" and press Enter.
- For Linux: Press
- Enter the SSH command: In the terminal, use the following command to initiate an SSH connection (see Fig. 1):
$ ssh username@ip_address
- Replace the
username
with the username you want to log in as (this is oftenroot
or a user with admin privileges). - Replace
ip_address
with the actual IP address or host name of your Linux server
$ ssh root@5.199.162.89
Fig. 1. SSH connection attempt with authentication prompt for a remote server. - Replace the
- Provide your password: After running the SSH command, you will be asked to enter your password. Type the password carefully and press
Enter
. Note that the password won't appear on the screen while typing for security reasons, but it is still being entered correctly (see Fig. 2).
Fig. 2. Password prompt after initiating SSH connection to the remote server. - Specify a custom SSH port (if applicable): If your server is using a port other than the default SSH port (
22
), include the-p
flag followed by the correct port number:
$ ssh username@ip_address -p custom_port
Replacecustom_port
with the port number your server's SSH service uses.
Example:$ ssh user@5.199.162.89 -p 2222
- Access the Server: After successful authentication, you will be connected to the remote server, and you can start executing commands (see Fig. 3).
Fig. 3. Successful login to Ubuntu 22.04.5 LTS on a remote server. You can see system information such as system load, memory usage, and available updates.
Connecting to a Linux server from Windows
On Windows, SSH connections can be made using either the built-in Windows terminal (available on Windows 10 and later) or third-party applications such as PuTTY..
Option A: Using Windows terminal (or PowerShell)
- Open Windows Terminal or PowerShell:
- Press
Windows + X
and select Windows Terminal or PowerShell from the menu. - Alternatively, search for Windows Terminal or PowerShell in the Start menu.
- Press
- Enter the SSH command: In the terminal, run the following command (see Fig. 4):
$ ssh username@ip_address
Example:$ ssh root@5.199.162.89
Fig. 4. SSH connection attempt from a Windows terminal to a remote server with ECDSA key fingerprint verification. - Provide your password: After entering the SSH command, you will be prompted to type your password. Enter it and press
Enter
. Once authenticated, you will be logged into the Linux server (see Fig. 5).
Fig. 5. Password prompt after initiating SSH connection to the remote server from a Windows terminal. - Specify a Custom SSH Port: If your server uses a non-default port, append the
-p
flag to the command with the appropriate port number:$ ssh username@ip_address -p custom_port
Option B: Using PuTTY
PuTTY is a popular third-party SSH client for Windows users.
- Download and install PuTTY: Download PuTTY from the official website: https://www.putty.org and install it (see Fig. 6).
Fig. 6. PuTTY setup wizard for installing the SSH client on a Windows system. - Launch PuTTY: Open PuTTY from the Start menu or a desktop shortcut (see Fig. 7).
Fig. 7. Windows search showing the PuTTY application after installation, ready to be launched for remote access via SSH. - Enter the server IP address:
- In the Host Name (or IP address) field, input the server's IP address (e.g.,
5.199.162.89
) (see Fig. 8).
Fig. 8. PuTTY configuration window with the IP address entered under the "Host Name (or IP address)" field for initiating an SSH connection. - Ensure the SSH connection type is selected and the port is set to
22
(or your custom port, if applicable) (see Fig. 9).
Fig. 9. PuTTY configuration window showing the IP address and port number (22) configured for an SSH connection.
- In the Host Name (or IP address) field, input the server's IP address (e.g.,
- Click Open: Press the
Open
button to start the connection (see Fig. 10).
Fig. 10. The PuTTY configuration window showing the "Open" button is highlighted, and it is ready to initiate the SSH connection. - Provide your username and password: When the terminal window appears, it will prompt you for your username and password. Enter the credentials to access the server (see Fig. 11).
Fig. 11. PuTTY terminal window prompting for the root password after successfully initiating an SSH connection to the remote server.
Closing the SSH connection
Once you have finished working on the server, it’s essential to close the SSH session properly.
- Type the Exit command: To log out of the server and close the connection, type the following command and press Enter:
$ exit
- Session Closed: The terminal window will close, or you’ll be returned to your local machine’s terminal.
Summary
In this tutorial, we have explored how to connect to a Linux server via SSH from various operating systems:
- On Linux and macOS, you can use the built-in terminal.
- You can use Windows Terminal/PowerShell or the PuTTY application on Windows.
With these steps, you can securely and efficiently connect to your Linux server from any platform. If the server uses a custom SSH port, remember to include the -p
option.