|
| 1 | +# Generating an SSH Key (Windows 10) |
| 2 | + |
| 3 | +## Steps |
| 4 | + |
| 5 | +The following steps are options if you wish to use an SSH Private Key. These steps were written for Windows 10, however, on Linux the steps are similar. |
| 6 | + |
| 7 | +1. Open PowerShell: |
| 8 | +2. **Generate key** (_with old PEM format_) |
| 9 | + 1. `ssh-keygen -m PEM -t rsa -b 4096` |
| 10 | + 2. In the future, we'll be able to use `ssh-keygen`.. just not yet. |
| 11 | +3. Set output name (_default is okay for basic setups_) |
| 12 | +4. Input a passphrase for the key _(OPTIONAL)_ |
| 13 | +5. Windows will now generate your RSA public/private key pair. |
| 14 | + 1. Default location: `%UserProfile%\.ssh` (WINOWS) |
| 15 | + 2. The public key will be stored as `id_rsa.pub` in the directory |
| 16 | +6. **Upload the public key** to your remote machine |
| 17 | + 1. Navigate to folder, `~/.ssh/` on Linux device |
| 18 | + 2. If `~/.ssh/authorized_keys` exists, append the contents of `id_rsa.pub` to the next line. |
| 19 | + 3. If it does not exist, simply upload `id_rsa.pub` and rename it to, `authorized_keys` |
| 20 | +7. Test your connection using SSH on Windows via `ssh user@hostname` |
| 21 | + |
| 22 | +## Convert Key to PEM format |
| 23 | + |
| 24 | +SSH.Net still has some issues with ssh-rsa. To overcome this, you'll need to convert keyfile to PEM. |
| 25 | + |
| 26 | +```powershell |
| 27 | +ssh-keygen -p -P "OLD_PASSPHRASE" -N "NEW_PASSPHRASE" -m pem -f "%UserProfile%\.ssh\id_rsa" |
| 28 | +``` |
| 29 | + |
| 30 | +## Sample output |
| 31 | + |
| 32 | +```cmd |
| 33 | +C:\workXXXXXX> ssh-keygen -m PEM -t rsa -b 4096 |
| 34 | +Generating public/private rsa key pair. |
| 35 | +Enter file in which to save the key (C:\Users\XXXXX/.ssh/id_rsa): |
| 36 | +Enter passphrase (empty for no passphrase): |
| 37 | +Enter same passphrase again: |
| 38 | +Your identification has been saved in C:\Users\XXXXXX/.ssh/id_rsa. |
| 39 | +Your public key has been saved in C:\Users\XXXXX/.ssh/id_rsa.pub. |
| 40 | +The key fingerprint is: |
| 41 | +SHA256:ETNWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXcms YYYYYYY\XXXXX@ZZZZZZZZ |
| 42 | +The key's randomart image is: |
| 43 | ++---[RSA 3072]----+ |
| 44 | +| oO=o | |
| 45 | +| XXXXXXXXXXXX | |
| 46 | +| XXXXXXXXXXXX | |
| 47 | +| XXXXXXXXXXXX | |
| 48 | +| XXXXXXXXXXXX | |
| 49 | +|+XXXXXXXXXXXX | |
| 50 | +|.XXXXXXXXXXXX | |
| 51 | +|oXXXXXXXXXXXX | |
| 52 | +|o+.. | |
| 53 | ++----[SHA256]-----+ |
| 54 | +``` |
| 55 | + |
| 56 | +## Reference |
| 57 | + |
| 58 | +* [https://www.onmsft.com/how-to/how-to-generate-an-ssh-key-in-windows-10] |
0 commit comments