How to create SSH public key for Windows user

### "What is SSH key?"
An SSH key consists of a “private key” and a “public key”.
A SSH public key(.ssh/id_rsa.pub) is exactly what is used to “publish” and grant access to a particular service or server. It is used to allow a host to grant access to a particular service or server.
In contrast, SSH private keys (`id_rsa`) should never be shared or given to others**.


I am a Windows user, I explain how to create SSH key for Windows user. If you are Mac / Linux user, you just open terminal and do from "How to create an SSH key"
But Windows user, you have to to set up Linix enbironment before creating SSH key.
WSL2 (Windows Subsystem for Linux 2) is a feature for running a Linux environment on Windows; it is available by default on the latest version of Windows 10/11.﻿

### "How to set up WSL2 for Windows user"

STEP1
・ Install WSL2
(If you don't have the WSL2 terminal set up yet) --my pc did not have WSL2.


・Open PowerShell as Administrator(type "powershell" and right click then select 'Run as Administrator' ) 
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/1ce2c74a-f078-cc18-9147-10915b2d4d2d.png)

・Type that in Powershill 
```
wsl --install
```
This command will install WSL and set WSL2 as the default version. It will also install the Ubuntu distribution by default.

Step2 
Set Up WSL2
After restarting, you should find the Ubuntu app in your Start menu. Open it to complete the installation.
You'll be prompted to create a new user account and password for your WSL2 distribution.

Step3
Open your WSL2 terminal (Ubuntu). See "How to create an SSH key"
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/f89b530e-0855-4c28-39e2-34ae8bdfaf77.png)
*Installing WSL2 (Windows Subsystem for Linux 2) allows you to use various Linux distributions, including Ubuntu, on Windows.
It's inside Ubuntu looks like.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/cfae59d1-8652-3bdd-12b1-e4803ac97303.png)



### "How to create an SSH key" 

From the computer that you normally use to SSH to our servers:

Windows: Use WSL2 
Mac / Linux: Open terminal
(This time, I am explaining for Windows user.)

STEP 1
Type that in "Ubuntu". (NOT in Windows powershell!)
```
ssh-keygen -t rsa
```
It is for the directory to contain the key.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/544afa06-5256-380a-f52d-49f6b7a3fbce.png)
Hit enter.

STEP2
Insert password you like twice.
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/499861c8-9813-e003-b42f-aa5259ada6f5.png)
*Ttps:The password entered is not displayed.The password entered is not displayed. (At first I panicked, thinking my keyboard was broken, but never mind, just press enter calmly when you finish typing the password.)
*Important:Be sure to keep track of the passphrase, because you must enter the passphrase whenever you use the key.

STEP3
Type this.
```
cat .ssh/id_rsa.pub
```
This command is used to display the contents of the SSH public key (id_rsa.pub)

STEP4
Copy and paste the contents (alphabets start from 'ssh-rsa') to Host along with email address.

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/3817969/309058af-03f9-5c79-edf9-bd5be74431e2.png)


References:
https://docs.acquia.com/acquia-cloud-platform/manage-apps/command-line/getting-started/generate
My lab members' Tips
Chat-GPT :)