Passwordless SSH Authentication on Windows 11

Setting up SSH keys for passwordless authentication on Windows 11 allows you to securely access remote servers without entering a password on every connection. This guide walks you through generating a secure cryptographic key pair using the native OpenSSH client, transferring the public key to your remote server, and verifying the passwordless connection.

Step 1: Open Windows Terminal or PowerShell

Windows 11 includes the OpenSSH Client by default. To begin, open PowerShell or Windows Terminal by right-clicking the Start button and selecting Terminal or PowerShell.

Step 2: Generate an SSH Key Pair

Run the ssh-keygen command to create a new SSH key pair. The Ed25519 algorithm is recommended for optimal security and performance:

ssh-keygen -t ed25519 -C "your_email@example.com"
  1. File location: Press Enter to accept the default file path (C:\Users\YourUsername\.ssh\id_ed25519).
  2. Passphrase: Press Enter twice to leave the passphrase empty for completely passwordless logins, or provide a passphrase to secure the private key on your local machine.

Your private key (id_ed25519) and public key (id_ed25519.pub) are now stored in the .ssh folder within your user directory.

Step 3: Copy the Public Key to the Remote Server

You must append the contents of your public key (id_ed25519.pub) to the ~/.ssh/authorized_keys file on the remote machine.

In PowerShell, run the following command (replace username and remote_host with your actual server credentials):

type $env:USERPROFILE\.ssh\id_ed25519.pub | ssh username@remote_host "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

You will be prompted to enter your remote server’s password one last time to complete the transfer.

Step 4: Test the Passwordless Connection

Test the configuration by connecting to your server via SSH:

ssh username@remote_host

If configured correctly, the server will authenticate you using your key pair and log you in immediately without prompting for your account password.

Optional: Configure the SSH Config File

To simplify your connection commands, create an SSH configuration file:

  1. Create or open the config file in Notepad:

    notepad $env:USERPROFILE\.ssh\config
  2. Add the server details:

    Host myserver
        HostName remote_host
        User username
        IdentityFile ~/.ssh/id_ed25519
  3. Save and close the file. You can now connect simply by typing:

    ssh myserver