Generating RSA-SSH Public Key, OpenSSH & PuTTY Compatible Private Keys using PuTTYgen.
In a consideration of security, most of the remote SSH connectivity are now transforming to Password-less RSA Authentication. Basically in this method, authentication is being done on the basis of Private / Public key. In which, Server will have a Public Key and a Client should have corresponding Private key for authentication in order to connect to the Server. In this demonstration we’ll see how to generate Public Key,OpenSSH formatted Private and PuTTY compatible RSA-SSH Private key. So that you can connect using both. PuTTy as well as OpenSSH (Linux / Unix Terminal).
1. Download PuTTYgen from the official website, and Install it.
2. After installation launch it.
- Click on Generate.
- Move the mouse pointer in the blank area to generate a random key.
- Once we’re done generating key, first click on Conversions and then Export OpenSSH key to export key in OpenSSH format.
- Enter passphrase or to continue without passphrase, click on Yes.
- And save it in anyname.ssh format. for OpenSSH. Which can be used to login through Linux / Unix Terminals.
- Once we’ve saved it in OpenSSH format, let’s save it in anyname.ppk PuTTY Private Key format. Click on Save Private Key as shown in the screenshot.
- Save it in anyname.ppk formate so that we can use it when want to login through PuTTY.
- Now we have Private key in both the formats, OpenSSH(.ssh) and PuTTY Private Key(.ppk). Let’s now save Public Key which we can export on a server. To save Public Key, Copy entire texts without missing a single character as shown in the screenshot.
- Paste it in any text editor, and save it as anyname.pub Public Key format.
- Now we have Public Key to export on server, like Oracle Cloud VM for RSA Based Authentication. And we do also have Private Keys in both OpenSSH and PuTTY Private Key format so that we can connect from Linux / Unit Terminals or PuTTY SSH Client.
3. Connecting using PuTTY.
- Enter IP or DNS of your Server.
- Then expand SSH and Click on Auth without expanding it. Import your PuTTY Private Key from the folder where you’ve saved it. and click on Open. You’ll be logged in via RSA Based Authentication.
4. Connecting Using OpenSSH.
[[email protected] keys]$ ssh -i RSASSH.ssh [email protected] [[email protected] ~]$
One more thing to keep in mind, while connecting via OpenSSH. make sure your Private Key has 400 permission.
- If you get Private Key too Open error while connecting using this method. change permission of Private Key to 400. to perform this operation you’ll need to login as a root user.
[[email protected] keys]# chmod 400 RSASSH.ssh
And then try, you should be able to login now.
Cheers! we’re done creating RSA based SSH keys for password-less authentication.