Are you searching the ways to generate ssh key in Windows 10 or any older version? Don’t worry; we have listed two easy methods. Let’s begin with the introduction to SSH keys.
What is SSH?
Secure Shell, also known as SSH is network protocol that ensure the secure connection between client and the server. The SSH protocol is used for system administration ( login, remote command-line, command execution) and file transfer over insecure networks. It can be used in all Linux and Unix systems. SSH was developed by Tatu Ylönen in 1995. SSH is commonly used to connect to servers remotely.
Setup SSH keys (Public and Private)
Setting up an SSH key is not that hard and can be done in few steps. SSH authentication relies on asymmetric cryptographic algorithms that generate a pair of separate keys (a key pair), one “private” and the other “public”. Private keys are stored in your local computer where public keys are uploaded to server.
(Method 1) Generate SSH Keys Using PuTTY
PuTTYgen is installed automatically with PuTTY software. Download PuTTY installation package for windows From HERE. Choose 32 bit or 64 bit version according to your system. Open the installer and click Next. Choose the installation directory and install. It will take few minutes. PuTTY is used to connect to the server using SSH protocol.
PuTTYgen is an key generator tool for creating SSH keys for PuTTY. Now, from startmenu search Puttygen and open the program. You can choose different format of keys. ( SSH-2 RSA with 2048 bit key size is most used configuration).
- Click Generate
- Move your mouse around the screen to create randomness in your keys
- As you move the mouse the green bar will advance and the keys will be generated
- After keys are generated, enter “Key Passphrase” and save Public Key and Private key. You can use Public key to upload it to server.
(Method 2) Generate SSH keys Using Command Line
If you are on latest version of Windows 10, you might have already OpenSSH installed by default. To make sure go to Start menu and launch Settings app. Browse Apps option and click Optional features in Apps and features window (as shown below).
Find OpenSSH Client in the list. If it is not installed by default in your system, click Add feature option and click OpenSSH from the list.
You can also install OpenSSH using Git. The Git installation package comes with SSH. Using the Git bash, you can generate the ssh key pairs. At first download and install Git to your computer (Download here) . Accept all the default components durng installation. Add the installation directory to Environment of your OS to access the git commands from Command Promp (CMD) or you can directly use Git Bash.
- Open Git Bash or CMD (only if git commands are accessible through cmd)
- Go to your user directory
$ cd C:\Users\<UserName>
- Check if .ssh folder is available using ‘ls’ command else create .ssh directory
$ mkdir .ssh
- To generate ssh keys type (the flags after ssh-keygen are optional, they are for configuration):
$ ssh-keygen -t rsa -b 2048 -C "your_email"
- SSH keygen command will generate key pairs and save to .ssh folder. You will be asked for file name which can be left default or you can set custom filename. In next step, enter the passphrase (it is optional too, can be left blank) Note that the passphrase won’t be visible while typing for security purpose. And you are done. Great!!
You can find public and private keys files in “C:\Users\<Username>\.ssh” folder. Upload the public key file (one with .pub extension) to your server. So we have learned two ways to generate SSH keys in Windows 10. You can also use Method 2 to create ssh key in Linux and Mac. Now you can connect to your server securely using ssh protocol. Type “ssh user@hostname” in bash or cmd to connect to the server from