How to Connect to Windows Server from Linux Using SSH on Windows 10

In modern IT environments, seamless connectivity between different operating systems is crucial. Linux and Windows servers often need to communicate for administration, file sharing, or other services. SSH (Secure Shell) is a powerful protocol widely used to manage systems remotely and securely. Although Windows servers do not traditionally come with SSH enabled, Windows 10 and later versions now include OpenSSH, making connecting from Linux to Windows servers easier. This article outlines a step-by-step guide to achieve this connectivity.


Why Use SSH?

SSH is a secure protocol to access remote machines over an encrypted connection. It ensures the safety of sensitive data, making it an ideal choice for system administrators who manage servers remotely. By using SSH, you can:

  • Remotely administer a server or computer.

  • Securely transfer files.

  • Run commands and manage services on remote systems.


Setting Up OpenSSH on Windows Server

Before connecting to a Windows server via SSH, you must ensure that OpenSSH is installed and properly configured. Here’s how to do it:

Step 1: Install OpenSSH Server on Windows 10

  1. Open Settings:

    • Press Windows + I to open the Settings menu.

  2. Go to Apps:

    • Navigate to Apps > Optional Features.

  3. Add OpenSSH Server:

    • Scroll down and click on "Add a feature."

    • Search for "OpenSSH Server."

    • Select it and click "Install."

  4. Wait for Installation:

    • The installation process may take a few minutes.

Step 2: Enable and Start the SSH Service

  1. Open PowerShell:

    • Press Windows + X and select PowerShell (Admin).

  2. Enable the Service:

    Set-Service -Name sshd -StartupType Automatic
  3. Start the Service:

    Start-Service sshd
  4. Allow SSH Through the Firewall:

    New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

Step 3: Verify SSH is Running

To check if the SSH service is running, you can use the following command:

Get-Service -Name sshd

Ensure the status is "Running."


Connecting to the Windows Server from Linux

Once SSH is set up on the Windows server, follow these steps to connect to it from a Linux machine.

Step 1: Open a Terminal on Linux

On your Linux machine, open a terminal application. Most Linux distributions come with a terminal pre-installed.

Step 2: Use the SSH Command

The basic syntax for the SSH command is:

ssh [username]@[Windows_Server_IP]

Replace [username] with the username of the Windows account you want to access, and [Windows_Server_IP] with the IP address of the Windows server.

For example:

ssh admin@192.168.1.10

Step 3: Accept the SSH Key

The first time you connect to the server, you’ll be prompted to accept the SSH key fingerprint. Type yes and press Enter.

Step 4: Enter the Password

After accepting the SSH key, you’ll be prompted to enter the password for the specified Windows user. Type the password and press Enter.

Once authenticated, you’ll be logged into the Windows server via SSH.


Transferring Files Between Linux and Windows Using SCP

You can also use the scp (Secure Copy Protocol) command to transfer files between Linux and the Windows server. Here’s an example:

Copying a File from Linux to Windows

scp /path/to/local/file username@Windows_Server_IP:/path/to/remote/directory

Copying a File from Windows to Linux

scp username@Windows_Server_IP:/path/to/remote/file /path/to/local/directory

Troubleshooting Common Issues

If you encounter problems, here are some troubleshooting tips:

  1. SSH Connection Refused:

    • Ensure the OpenSSH service is running on the Windows server.

    • Verify that port 22 is open and not blocked by a firewall.

  2. Authentication Failure:

    • Double-check the username and password.

    • Ensure the Windows user account has the necessary permissions.

  3. Host Key Verification Failed:

    • Remove the old SSH key from the ~/.ssh/known_hosts file on your Linux machine.

    ssh-keygen -R [Windows_Server_IP]

Advantages of Using SSH for Linux-Windows Connectivity

  • Security: Encrypted connections prevent unauthorized access and data theft.

  • Ease of Use: Simple commands allow efficient server management.

  • Cross-Platform Compatibility: Works seamlessly between Linux and Windows.

  • File Transfers: Facilitates secure file sharing across platforms.


Conclusion

Connecting to a Windows server from a Linux machine using SSH on Windows 10 is now straightforward, thanks to the inclusion of OpenSSH. Following the steps outlined in this guide, you can securely manage your Windows server from a Linux terminal. Whether you’re transferring files, running commands, or managing services, SSH provides a robust and secure solution for cross-platform connectivity.

If you’re new to SSH or encountering issues, refer to the troubleshooting section or consult official documentation for additional help.

Comments

Popular posts from this blog

How to Connect to a Linux Server from Windows Using MobaXterm

How to Allow Remote Desktop Connections on Windows 7

How to Secure a Windows VPS from Hackers: A Comprehensive Guide