In the evolving landscape of IT management, secure and efficient remote access to your servers is critical. With Windows Server 2022, you can enable SSH (Secure Shell) for secure command-line access, facilitating better automation and management. I wanted to try this out recently, to see if it would work with Visual Studio Code’s Remote Development Extension. I won’t cover that in this post, since I’m still experimenting with it at the time I’m writing this.

This guide will walk you through the process of enabling and configuring the SSH server on your Windows Server 2022.

Why Use SSH on Windows Server? Link to heading

SSH provides a secure channel over an unsecured network, allowing encrypted communication and secure login from a remote computer. It’s widely used for remote management and automation, offering numerous benefits:

  • Security: Encrypted connections protect data integrity and confidentiality.
  • Automation: Easily script and automate administrative tasks.
  • Compatibility: Standardized protocol compatible with many tools and platforms.

Step-by-Step Guide to Enable SSH on Windows Server 2022 Link to heading

If you are looking for a fully automated method, see Configuring SSH Access on Windows Server 2022 Using PowerShell.

Step 1: Install OpenSSH Server Link to heading

  1. Open Windows Settings:

    • Press Win + I to open the Settings app.
  2. Navigate to Apps:

    • Go to Apps > Optional Features.
  3. Add a Feature:

    • Click on Add a feature.
  4. Install OpenSSH Server:

    • In the search box, type “OpenSSH Server” and select it.
    • Click Install.

Step 2: Start and Configure the SSH Service Link to heading

  1. Open PowerShell as Administrator:

    • Right-click on the Start button and select Windows PowerShell (Admin).
  2. Start the SSH Service:

Start-Service sshd
  1. Set SSH to Start Automatically:
Set-Service -Name sshd -StartupType 'Automatic'
  1. Confirm the Firewall Rule: Ensure that the firewall allows SSH traffic.

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

Step 3: Verify SSH Configuration Link to heading

  1. Check the SSH Service Status:

    Get-Service -Name sshd
    
  2. Connect via SSH: From a remote machine, use an SSH client (e.g., PuTTY, OpenSSH) to connect to the Windows Server using its IP address:

    ssh username@your_server_ip
    

    Replace username with your Windows account username and your_server_ip with your server’s IP address.

Additional Configuration Link to heading

Configuring SSH Key-Based Authentication Link to heading

  1. Generate SSH Keys: On your client machine, generate a key pair:

    ssh-keygen
    
  2. Copy the Public Key to the Server: Use the following command to copy your public key to the server:

    ssh-copy-id username@your_server_ip
    
  3. Edit SSH Configuration (Optional): You may want to edit the SSH configuration file (sshd_config) for advanced settings. This file is typically located in C:\ProgramData\ssh\.

    Example to disable password authentication:

    PasswordAuthentication no
    

Conclusion Link to heading

Enabling SSH on Windows Server 2022 enhances your ability to manage and automate tasks securely and efficiently. With SSH, you can leverage the power of remote command-line access, improving your administrative capabilities and streamlining operations.


Emmanuel Tsouris is a Systems Development Manager working in the cloud, with extensive experience in cloud platforms, enterprise management, and automation. In his spare time, he enjoys hiking, biking, cooking, photography, and writing. For more insights and tips, visit emmanueltsouris.com.