Table of Contents
- Install PuTTY and PuTTYgen
- Use Existing Public and Private Keys
- Create New Public and Private Keys
- Copy Public Key to Server
- Connect to Server with Private Key
SSH can handle authentication using a traditional username and password combination or by using a public and private key pair. The SSH key pair establishes trust between the client and server, thereby removing the need for a password during authentication. While not required, the SSH private key can be encrypted with a passphrase for added security.
The PuTTY SSH client for Microsoft Windows does not share the same key format as the OpenSSH client. Therefore, it is necessary to create a new SSH public and private key using the PuTTYgen tool or convert an existing OpenSSH private key.
- PuTTY SSH client for Microsoft Windows
- Remote server accessible over OpenSSH
Install PuTTY and PuTTYgen
Both PuTTY and PuTTYgen are required to convert OpenSSH keys and to connect to the server over SSH. These two tools can be downloaded individually or, preferably, as a Windows installer from the PuTTY Download Page.
Once the PuTTY Windows installer is downloaded, double-click the executable in the Download folder and follow the installation wizard. The default settings are suitable for most installations. Both PuTTY and PuTTYgen should now be accessible from the Windows Programs list.
Use Existing Public and Private Keys
If you have an existing OpenSSH public and private key, copy the
id_rsa key to your Windows desktop. This can be done by copying and pasting the contents of the file or using an SCP client such as PSCP which is supplied with the PuTTY install or FileZilla.
Next launch PuTTYgen from the Windows Programs list.
Conversionsfrom the PuTTY Key Generator menu and select
- Navigate to the OpenSSH private key and click
Save the generated key, select
Save private key.
- Choose an optional passphrase to protect the private key.
- Save the private key to the desktop as
If the public key is already appended to the
authorized_keys file on the remote SSH server, then proceed to Connect to Server with Private Key.
Otherwise, proceed to Copy Public Key to Server.
Create New Public and Private Keys
Launch PuTTYgen from the Windows Programs list and proceed with the following steps.
Parameters, increase the
Number of bits in a generated key:to a minimum value of 2048.
Generate a public/private key pair, click
- You will be instructed to move the mouse cursor around within the PuTTY Key Generator window as a randomizer to generate the private key.
- Once the key information appears, click
Save private keyunder
Save the generated key.
- Save the private key to the desktop as
- The box under
Public key for pasting into OpenSSH authorized_keys file:contains the public key.
Copy Public Key to Server
The OpenSSH public key is located in the box under
Public key for pasting info OpenSSH authorized_keys file:. The public key begins with ssh-rsa followed by a string of characters.
- Highlight entire public key within the PuTTY Key Generator and copy the text.
- Launch PuTTY and log into the remote server with your existing user credentials.
Use your preferred text editor to create and/or open the
Paste the public key into the
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQBp2eUlwvehXTD3xc7jek3y41n9fO0A+TyLqfd5ZAvuqrwNcR2K7UXPVVkFmTZBes3PNnab4UkbFCki23tP6jLzJx/MufHypXprSYF3x4RFh0ZoGtRkr/J8DBKE8UiZIPUeud0bQOXztvP+pVXT+HfSnLdN62lXTxLUp9EBZhe3Eb/5nwFaKNpFg1r5NLIpREU2H6fIepi9z28rbEjDj71Z+GOKDXqYWacpbzyIzcYVrsFq8uqOIEh7QAkR9H0k4lRhKNlIANyGADCMisGWwmIiPJUIRtWkrQjUOvQgrQjtPcofuxKaWaF5NqwKCc5FDVzsysaL5IM9/gij8837QN7z rsa-key-20141103
Save the file and close the text editor.
Adjust the permissions of the
authorized_keysfile so that the file does not allow group writable permissions.
chmod 600 ~/.ssh/authorized_keys
Logout of the remote server.
Connect to Server with Private Key
Now it is time to test SSH key authentication. The PuTTYgen tool can be closed and PuTTY launched again.
- Enter the remote server Host Name or IP address under
- Navigate to
Private key file for authentication.
- Locate the
id_rsa.ppkprivate key and click
- Finally, click
Openagain to log into the remote server with key pair authentication.
When .ssh folder is not created already on server, you need to create folder and change permission with below commands-
mkdir ~/.ssh chmod 640 ~/.ssh
now you can create authorized_key file to copy public key on remote linux server.
You can add a comment in "Key comment" box to make the more identical.
When using sshkey authentication to access internal systems (e.g. through a bastion host) "Allow agent forwarding" must be enabled within the authentication parameters.
Hi, I can do a one-time key-based authentication using the above steps but if I quit putty and try to login again, I need to redo all the steps again. how do I make this update global ? also I want superputty to be able to do key-based auth.
@hprof After to import file .ppk return session and click button save
Server refused our key
I'm asked "login as". Why would openssh ask for a username if i'm using cryptographic certificates to login ? Also, i'm looking for a solution where the server requires a cryptographic key to login in order to deny brute forcing login attempts through port 22.
hi thanks for this tut but i have problem when i use Private key in putty i get Server refused our key
service ssh status ==> https://ibb.co/bKqWK7
putty ==>> https://ibb.co/fm6hRn
iptable ==>> https://ibb.co/dX2iXS
ufw ==> https://ibb.co/b9XBK7
ubuntu ip ==> 192.168.1.19
windows ip ==> 10.42.0.120
share my wifi from ubuntu to windows
@jack and @madskr1, are the permissons on your .ssh directory and the authorized_keys file set correct? .ssh needs to be set to 700 and authorized_keys to 600.
I carefully applied all 5 steps which you mentioned on this post to connect to Server by the using of Private Keys. Really this post is very helpful for me. Keep sharing this type of post. Resolve your HP Computer related problem at https://hpetechnicalsupportnumber.com/hp-computer-support/
I was really upset with that problem. I have tried a lot even I took help from at http://www.outlooktechnicalsupportnumbers.com/ but nothing works. I have tried your steps. It really works. Thank you!
To make and use e SSH keys on Windows, you have to download and introduce both PuTTY, the utility used to interface with remote servers through your wifi. If you getting any of issue in downloading through your interent or router then visit here https://www.belkinroutersupportnumber.com/
You can use PuTTY to generate SSH keys. PuTTY is a free open-source terminal emulator that functions much like the Terminal application in macOS in a Windows environment. Visit http://www.acersupportnumber.com/blog/fix-windows-10-keeps-restarting-on-acer-laptop/