# Convert PuTTY Key to OpenSSH Key

### Install PuTTYgen <a href="#install-puttygen" id="install-puttygen"></a>

If you don’t have **`putty-tools`** on **Linux**, install it at first.

```shellscript
# Install in Linux
sudo apt install putty-tools
```

If you use **`puttygen`** on **Windows**, install the **PuTTYgen** in the official page.

### Generate Key Pair <a href="#generate-key-pair" id="generate-key-pair"></a>

```shellscript
# -t: key type
# -b: number of bits
# -C: key comment
# -o: output file
puttygen -t rsa -b 2084  -C "user@example.com" -o keyfile.ppk
```

#### PuTTY to SSH Key <a href="#putty-to-ssh-key" id="putty-to-ssh-key"></a>

If you use **`puttygen`** on **Linux**, run the following command to convert PuTTY key to **OpenSSH** keys (private/public).

```shellscript
# SSH private key
puttygen keyfile.ppk -O private-openssh -o id_rsa

# SSH public key
puttygen keyfile.ppk -O public-openssh -o id_rsa.pub
```

If you use **`puttygen`** on **Windows**, follow these steps:

1. Open **PuTTYgen**.
2. Click on **Conversions → Import key** at the top menu. Then upload the PuTTY key file (**`.ppk`**).
3. After uploading, click on **Conversions → Export OpenSSH key**.
4. The **OpenSSH** private key will be downloaded.
