Windows Terminal is one of my most loved features of recent Windows releases. Seriously Microsoft, where was this application in Windows 2000? I can launch Powershell, Command Prompt and ssh sessions from the same window - simply amazing! (Yes, I know that Linux has supported this for decades).
I wanted to create a profile that would let me administer my omv Linux server, without having to input credentials every. single. time. To do that, a public/private key needs to be created, before copying the public key over to the destination server. Then, when I connect via. SSH and present my private key, the connection is transparently (to me) approved.
Start by running the command ssh-keygen -t rsa
to generate a keypair. I accepted all the defaults, and skipped a passphrase:
C:\Users\Greg>ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Greg/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Greg/.ssh/id_rsa.
Your public key has been saved in C:\Users\Greg/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:IaBSPSCx3y416+iY7qLYbMf9FoxBNhSNbAR/SMRh5yM greg@DESKTOP-SU06DHB
The key's randomart image is:
+---[RSA 3072]----+
|o.oooBO=. |
| + .o=O+. |
|o . =E.= |
| o . .+ o |
| . + +S |
| o o. o |
| ..o. . |
|o=.+o . . |
|X==.. o. |
+----[SHA256]-----+
C:\Users\Greg>
Now we copy the public key over to the omv server:
cat ~/.ssh/id_rsa.pub | ssh root@192.168.4.107 "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
Finally, we setup the connection profile in Windows Terminal via. Launch Terminal > Settings > Open JSON
Paste this configuration string into the profiles section. You’ll need to update the username and IP address to reflect your situation:
{
"commandline": "ssh -i \"~/.ssh/id_rsa\" root@192.168.4.107",
"font": {"size": 10.0},
"guid": "{0caa0dad-35be-5f56-a8ff-afceaeaa6103}",
"hidden": false,
"name": "OMV Server"
}
Save the settings, then test the connection!