Since Windows cmd can't use ssh command, and I failed many times to set up key when use PuTTY, so I recommend use the OpenSSH for Windows to set up your key.
Install OpenSSH
- Go to the OpenSSH for Windows download page
- Choose
Binary Installer Releases
- Download the .zip file
- Extract zip file and install it
Confirm installation is success or not
- Open command line (If you don't know how to open it, you can use
windows key + R
and inputcmd
then clickOK
) - Input
ssh
then you will see some usage of ssh command
Create the key pair
- Open command line
- Enter to target folder. eg:
cd C:\Users\<User Name>
- Input
ssh-keygen -t rsa
, you will see the message like below
Generating public/pricate rsa key pair.
Enter file in which to save the key (/c/Users/<User Name>/.ssh/id_rsa):
Created directory '/c/Users/<User Name>/.ssh'.
- It will asking you a password for the key when access, if you don't want to use pass word, just pass it (enter twice). The message will like:
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/<User Name>/.ssh/id_rsa.
Your public key has been saved in /c/Users/<User Name>/.ssh/id_rsa.pub.
The key fingerprint is:
88:55:55:ff:ff:99:aa:e1:f4:a0:01:43:4e:e8:bc:ff <User Name>@desktop
Access git server
- Access server that confirm your key is set up success
ssh <username>@<server host name>
- First time to access server after set up the key, you will see the message as below
The authenticity of host 'host name(IP address)' can't be established.
RSA key fingerprint is 80:5f:25:7c:f4:90:aa:e1:f4:a0:01:43:4e:e8:bc:f5.
Are you sure you want to continue connecting (yes/no)?
- Input
yes
, and enter your server password - Then you will enter to server !