Secure Shell (SSH) is a widely used protocol for securely accessing remote servers, commonly employed on Linux systems. However, SSH can also be used to connect to a Windows server, particularly if you’re running Windows 10 or Windows Server 2019 and later, which come with built-in OpenSSH support. This guide explains how to connect to Windows Server from Linux using SSH Windows 10.
Prerequisites
Before starting, ensure you have the following:
- Windows Server Configuration
- The Windows server must have the OpenSSH Server feature installed and running.
- Administrative access to enable and configure the OpenSSH server.
- Linux System Configuration
- A Linux system with an SSH client installed. Most Linux distributions come with OpenSSH by default.
- Network Access
- A network connection between the Linux machine and the Windows server. Ensure firewalls or security settings allow SSH traffic (port 22 by default).
How to Connect to Windows Server from Linux Using SSH Windows 10 Step-by-Step Guide
Step 1: Install and Configure OpenSSH on the Windows Server
1.1 Check for OpenSSH Installation
On the Windows server:
- Open the Settings app.
- Navigate to Apps > Optional Features.
- Scroll down to check if the OpenSSH Server feature is listed. If it is not installed, follow the next step.
1.2 Install OpenSSH Server
- Open PowerShell as an administrator.
- Run the following command to install OpenSSH Server:
- Once installed, verify the installation:
1.3 Start and Configure the OpenSSH Service
- Start the OpenSSH service:
- Configure the service to start automatically:
1.4 Allow SSH Through the Windows Firewall
- Open PowerShell as an administrator.
- Run the following command to allow SSH traffic:
Step 2: Find the Windows Server’s IP Address
On the Windows server:
- Open a Command Prompt or PowerShell window.
- Run the following command to find the server’s IP address:
- Note the IPv4 address under the active network adapter.
Step 3: Test SSH Connection from Linux
3.1 Open the Terminal on Linux
Launch the terminal on your Linux system. SSH commands are run from the terminal.
3.2 Use the SSH Command
Run the following command to initiate an SSH connection to the Windows server:
- Replace
usernamewith the user account on the Windows server. - Replace
windows_server_ipwith the server’s IP address.
3.3 Accept the SSH Key
The first time you connect, SSH will ask to confirm the server’s fingerprint. Type yes and press Enter.
3.4 Enter the Password
Provide the password for the specified Windows account. Upon successful authentication, you’ll be connected to the Windows server.
Step 4: Troubleshooting Common Issues
4.1 Firewall or Network Issues
- Ensure port 22 is open on the Windows server firewall.
- Verify that there are no network restrictions or additional firewalls blocking SSH traffic.
4.2 Incorrect Username or Password
- Double-check the username and password. The username must exist on the Windows server.
4.3 SSH Service Not Running
- Verify that the OpenSSH service is running on the Windows server:
4.4 Key-Based Authentication Issues
- If using SSH keys, ensure the public key is added to the
authorized_keysfile on the Windows server. The default location is:
Step 5: Set Up Key-Based Authentication (Optional)
For enhanced security, configure SSH to use key-based authentication instead of passwords.
5.1 Generate SSH Keys on Linux
- Open the terminal and run:
- Save the key pair in the default location (usually
~/.ssh/id_rsa) and set a passphrase.
5.2 Copy the Public Key to the Windows Server
Use the ssh-copy-id command to copy the public key to the Windows server:
Alternatively, manually add the contents of the public key file (~/.ssh/id_rsa.pub) to the authorized_keys file on the Windows server.
5.3 Test Key-Based Authentication
Connect to the server without a password:
Step 6: Automate Tasks with SSH
Once connected, you can use SSH to execute commands on the Windows server, transfer files, or manage the server remotely. Here are a few examples:
6.1 Execute Commands
Run a command directly from Linux:
6.2 Transfer Files
Use scp to transfer files between your Linux system and the Windows server:
Security Tips for SSH
- Use Strong Passwords
Avoid using weak passwords to reduce the risk of unauthorized access. - Restrict Access
Limit SSH access to specific IP addresses using firewall rules. - Disable Password Authentication
Once key-based authentication is set up, disable password authentication in the OpenSSH configuration file (sshd_config). - Monitor Logs
Regularly review the SSH logs on the Windows server for unauthorized access attempts.
Conclusion
Connecting to a Windows server from a Linux system using SSH on Windows 10 is a straightforward process, thanks to the built-in OpenSSH support in modern Windows versions. By following the steps outlined in this guide, you can establish a secure and efficient connection for remote server management. With the added security of key-based authentication and proper configuration, you can ensure a robust and reliable setup for your SSH needs.



