Knowledgebase

Getting started connecting to servers with ssh keys from Windows

  • Windows, SSH, SSH key, ed25519
  • 1

Windows 10 and up has support for native ssh client, and can generate keys for used for authenticating servers. This can greatly simplify and the security of all aspects of the connections process there for is highly recommended to use on any internet connected server and disable password based alternatives. This allows secure authentication to the server or applications while never reveling to the server operator any password information and keep your passphrase and security info local.  

In the example below you can see both PowerShell and CMD can utilize ssh. 

More information can be found here with additional flags to change port or configure other aspects.  https://man7.org/linux/man-pages/man1/ssh.1.html

CMD and PowerShell SSH example

To generate your key pair run the following from powershell.

ssh-keygen -t ed25519

This will ask you where you would like the key to be placed it is recommended to use the default location, as your windows user account will then know where to find it automatically.
It will then ask for a passphrase if your running automated scripts that won’t be directly accessed from a workstation leave blank this will allow the current machine to connect with no further actions.
However, if this is an key intended to be used by the end user it is highly recommended to set a passphrase so in the event a key is lost or stolen it is useless without the passphrase.





Once the key is created it will have placed the file in “C:\Users\(user)\.ssh”  we highly recommend backing up these files now.


The id_ed25519 is your private key,  this should be kept safe and never exposed to another user to keep your login secure. The file that can be shared is id_ed25519.pub, this is known as the public key and can be freely shared to anyone looking to give you secured access to a system. Both of these are simple text files that can be opened in notepad or other text editors.

Location of windows SSH keys


As an example here is how you can now use this key with our VHI cloud.

Open the portal for your account and click on SSH keys on the bottom left side. Then find the button on the top right labeled + Add SSH key. 

Sharktech Portal Add ssh1

Open your  id_ed25519.pub file with a text editor an copy the contents in to the key value pair field of the form.

With that open add a name that make sense to you like the location of the pc with the key or the users name if you copy the key or leave this blank the form will use the pcs username and host.


Notepad opening SSH KEY FILE

 

You now can create a vm utilizing your ssh just add it during the initial creation, as shown below select the pencil icon for "SSH key" then select one or more keys that will be added to the server on first boot.

VHI Cloud  Vm CreationVHI Image creation Selecting Keypair

 

Once the vm is ready using ether CMD or PowerShell you can connect to it with your keypair and optional passkey. Please note most templets utilize a non root/admin username that corresponds to the os for example below almalinux is the username for an alma linux 9 install. If unsure most templets will tell you the correct login when you attempt to use root user ssh  root@yourIP

CMD and PowerShell SSH example




Once ssh keys are setup, to manage the keys on a linux based server use vi / nano /emacs to edit the file. Each line will be one ssh key. And should match what your public key file has in it.



Once thing to note if you edit with a gui based editor you may need to correct permissions afterword as ssh will refuse to read this file with incorrect permissions. Here is an ls example of what they should be on both the directory and file.

 

 


Was this answer helpful?