How to SSH on Windows

How to SSH on Windows

Secure Shell (SSH) is a powerful protocol for securely accessing remote systems. This guide walks you through setting up and using SSH on Windows, from installation to connecting to a remote server. Whether you’re a beginner or an experienced user, this tutorial covers everything you need to know.

Step 1: Check if SSH is Already Installed

Windows 10 (version 1803 and later) and Windows 11 include a built-in SSH client called OpenSSH. To check if it’s installed:

  1. Open the Command Prompt or PowerShell by pressing Win + S, typing cmd or powershell, and hitting Enter.
  2. Type the following command and press Enter:ssh -V
  3. If OpenSSH is installed, you’ll see a version number (e.g., OpenSSH_for_Windows_8.1p1). If not, you’ll get an error like “‘ssh’ is not recognized.”

If SSH is not installed, proceed to the next step.

Step 2: Install OpenSSH Client on Windows

Windows provides an easy way to install the OpenSSH client via the Settings app or PowerShell.

Option 1: Install via Settings

  1. Open Settings (Win + I).
  2. Navigate to Apps > Optional features.
  3. Click Add a feature, then search for OpenSSH Client.
  4. Select it and click Install.
  5. Wait for the installation to complete. You may need to restart your system.

Option 2: Install via PowerShell

  1. Open PowerShell as Administrator (right-click Start menu > Windows PowerShell (Admin)).
  2. Run the following command to install the OpenSSH Client:Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
  3. Verify installation by running:ssh -V

For a visual guide, watch this YouTube tutorial on installing OpenSSH on Windows.

Step 3: Generate SSH Keys (Optional)

SSH keys provide a more secure way to authenticate than passwords. To generate an SSH key pair:

  1. Open PowerShell or Command Prompt.
  2. Run:ssh-keygen -t rsa -b 4096
  3. Press Enter to accept the default file location (C:\Users\YourUsername\.ssh\id_rsa).
  4. Enter a passphrase (optional) or press Enter to skip.
  5. Two files are created:
    • id_rsa (private key)
    • id_rsa.pub (public key)

To learn more about SSH keys, check this video on SSH key generation.

Step 4: Copy Public Key to Remote Server

To use your SSH key for authentication, you need to add your public key to the remote server’s ~/.ssh/authorized_keys file.

  1. Copy your public key to the clipboard:type $env:USERPROFILE\.ssh\id_rsa.pub | clip
  2. Connect to the remote server using a password (replace username and server_ip):ssh username@server_ip
  3. On the remote server, create or edit the authorized_keys file:mkdir -p ~/.ssh echo "your_public_key" >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keysPaste your public key (from the clipboard) in place of your_public_key.

Alternatively, use ssh-copy-id if available:

ssh-copy-id username@server_ip

Step 5: Configure SSH for Easier Access

To streamline connections, you can create an SSH config file:

  1. Navigate to C:\Users\YourUsername\.ssh\ and create a file named config (no extension).
  2. Add the following content to the config file:Host myserver HostName server_ip User username IdentityFile ~/.ssh/id_rsa
  3. Save the file and set permissions:icacls "C:\Users\YourUsername\.ssh\config" /inheritance:r icacls "C:\Users\YourUsername\.ssh\config" /grant:r "%username%:F"

Now, connect to the server using:

ssh myserver

Step 6: Connect to a Remote Server

To connect to a remote server, use the SSH command:

ssh username@server_ip
  • Replace username with your remote server username.
  • Replace server_ip with the server’s IP address or hostname (e.g., 192.168.1.100 or example.com).

If you set up SSH keys, you won’t need a password. Otherwise, enter the password when prompted.

Step 7: Test and Troubleshoot

  • Test the connection: Ensure you can log in without issues.
  • Common issues:
    • “Connection refused”: Verify the server is running an SSH service (usually on port 22).
    • “Permission denied”: Check your username, password, or SSH key setup.
    • “Command not found”: Ensure OpenSSH is installed correctly.
  • For troubleshooting, refer to this Microsoft SSH documentation.

Step 8: Optional – Use Third-Party SSH Clients

If you prefer a graphical interface, consider third-party tools like:

  • PuTTY: A lightweight SSH client. Download from putty.org.
  • MobaXterm: A feature-rich terminal with a free version. Download from mobaxterm.mobatek.net.

For a tutorial on using PuTTY, watch this YouTube guide.

Conclusion

You’ve now learned how to install and use SSH on Windows, from setting up OpenSSH to connecting to a remote server. Whether you use the built-in OpenSSH client or a third-party tool like PuTTY, SSH is a powerful way to manage remote systems securely.

For further reading, check out:

  • Official OpenSSH documentation
  • Guide to SSH on Windows

Show 1 Comment

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *