Skip to content

Instantly share code, notes, and snippets.

@Kareszrk
Created January 10, 2025 07:12
Show Gist options
  • Save Kareszrk/77d10aa8f44aba80296d67381136e0f2 to your computer and use it in GitHub Desktop.
Save Kareszrk/77d10aa8f44aba80296d67381136e0f2 to your computer and use it in GitHub Desktop.
Add SSH key on windows 11

To add SSH keys for accessing your Ubuntu workstation from your Windows 11 machine, follow these steps:

  1. Generate an SSH key on Windows 11:

    • Open PowerShell or Command Prompt.
    • Run the following command to generate a new SSH key pair:
      ssh-keygen -t rsa -b 4096 -C "username@server_host"
    • Follow the prompts to save the key (default location is usually fine) and set a passphrase if desired.
  2. Copy the SSH public key to your Ubuntu workstation:

    • Use the ssh-copy-id command to copy your public key to the Ubuntu workstation. Replace username and hostname with your actual username and the workstation's hostname or IP address:
      ssh-copy-id username@hostname
    • If ssh-copy-id is not available on Windows, you can manually copy the key:
      • Display the public key with:
        cat ~/.ssh/id_rsa.pub
      • On your Ubuntu workstation, append the public key to the ~/.ssh/authorized_keys file:
        echo "your_public_key" >> ~/.ssh/authorized_keys
      • Ensure the correct permissions are set on the authorized_keys file:
        chmod 600 ~/.ssh/authorized_keys
  3. Connect to your Ubuntu workstation:

    • From your Windows 11 machine, use the ssh command to connect to your Ubuntu workstation:
      ssh username@hostname

This process will add a new SSH key for your Windows 11 machine without modifying the SSH key access for your other computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment