15.12.2020

Powershell Generate Ssh Key Windows10

Ssh

May 23, 2019 The first step to using key-based authentication is to generate a key pair - a set of matching public and private keys. The OpenSSH client capability in Windows includes the tools required to do so. Follow this process using PowerShell from the client computer you will be connecting from.

If ssh-agent is running, the keys will be automatically added to the local store. To make key authentication easy with an SSH server, run the following commands from an elevated PowerShell prompt: # Install the OpenSSHUtils module to the server. This will be valuable when deploying user keys. How to Generate SSH Public/Private Keys on Windows By Alexandru Andrei – Posted on Sep 17, 2019 Sep 17, 2019 in Windows If you ever managed a Linux server from Windows, you probably used PuTTY or at least heard about it.

Login With Password

  1. Workgroup users
    • ssh user@host
  2. Domain users: Prior to v7.7.0.0, domain needs to be explicitly specified. Any of the following formats work
    • ssh -l user@domain host
    • ssh domainuser@host
    • ssh user@domain@host
    • ssh user@host (works from v7.7.0.0 onwards provided user has no conflicts otherwise - ex. user exists both on local account data base and on domain)

Login With SSH Keys

Usage from client-side (ssh)

  1. Generate a key pair on the client (preferably with a passphrase):
    • ssh-keygen -t rsa -f id_rsa
  2. Register private key with ssh-agent (optional, for single sign-on experience)
    • net start ssh-agent
    • ssh-add id_rsa
  3. Login using private key
    • ssh -i .id_rsa user@host (workgroup user)
    • ssh -i .id_rsa -l user@domain host (domain user)
Ssh

Setup server-side (sshd)

  1. Append contents of id_rsa.pub (client's public key) to the following file in corresponding user's directory %systemdrive%Users<user>.sshauthorized_keys (create one if needed).
  2. Double check access permissions on authorized_keys (only System, Administrators and owner can have access).icacls %systemdrive%Users<user>.sshauthorized_keys

Login using Kerberos Authentication

Setup server-side

  1. On a domain joined server, set GSSAPIAuthentication to yes in sshd_config

Usage on a domain joined Windows client logged in as domain user

  • ssh -K host

Please note you have to use the hostname instead of the username.

For Unix and Linux users

The Modern Unix Rosetta Stone includes PowerShell examples of common Unix and Linux commands.

Powershell Add Ssh Key

Clone this wiki locally