How to recover access after disabling password authentication: What to do if keys are lost in Windows in PuTTY?

Disabling the password authentication on the server and have subsequently lost to server due to misplaced or disabled SSH key. Fortunately, SSH keys have backups ways to regaining the administration command line access even when password login is blocked. To re-establish access, steps can be made within PuTTY program.

It involves temporary enabling the password login in SSH server setting in order to build new SSH key pairs, issue public key and load related in PuTTY to restore authentication.

Also check how to use SFTP to uplaod file on Oracel server bu using PuTTY.

There are following steps to recover the access

Console access:

Access the server console access to get the direct access, use the server or cloud remote console access protocol.

Using PuTTYgen (PuTTY key generator):

If you have still the private key and lost the public key on the server. You can generate the public key on the PuTTYgen.

Open the PuTTYgen and Load your private key.

Go to ‘conversion’ menu and select the ‘Export OpenSSH key’. Save the public key.

Add the new public key to the ‘authorized key’ file on the server.

Restore backups:

If you have recent backups, trying restoring it on state where the password authentication is enabled and you have access.

Alternative account:

If you have another account with Administrative rights, log in with that account and add new SSH key.

Use alternative SSH clients:

If PuTTY is primary issue then, using another SSH clients like OpenSSH on Windows.

Contact support:

If your server is hosted by other provider then contact their supporting team is valuable resource to regaining access. Providers have the backup and other tools to assist user facing access issue.

Resetting password:

If you the administrative rights, you can reset password of account that you want to access. Open the command prompt with administrative rights and use the command

net user <username> <newpassword>

once the access is restoring then make the backups of the key prepare for any future loss. By storing the keys in Windows Credential Manager have automatic backup of keys in profile storage.