Private keys can be secured with a password to add an extra layer of protection. While this is often recommended for security reasons, there may be cases where you want to remove the password. This tutorial shows how to remove password from private key using ssh-keygen.
Let's say we have a private key file (id_rsa
) protected with the password testing123
:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABD07/2+3/
AnN30aFQ8H/y8GAAAAGAAAAAEAAACXAAAAB3NzaC1yc2EAAAADAQABAAAAgQDFHi1gv5z+
7K7I/ziOpM6FAjAPQwUtfc+0uR6Cw9PVwR/pgtq0Y03MzHX2vf+oxDW2464S3WbkDPK+Vv
Q+ofmGjmdeeaMPxLwn7alxMbUCC/jvpeCw5YtJ7mzUaooF6R/GCK8jeLIJSMd4P03UvwxA
dmixmbHyGXagzZ9y1q5SwQAAAhDa60XFucifDNb/DVRWlN7gBC+32pjMur3fFbbOwtXjMQ
NoZRxDCnpud7VsPH0hXRoEvJ+FU5Bb6b8kWefpfYS170TECLSCCM48ZD1ZR5G7GB+cGyPp
C24vVPm9uu8hkfcWQnk23Oyte06L52BtHe+UnfsRyNT13AsZMgOtICUWP3AxnvCYUUCSUt
8AkQnWzJbyj0UkRl4F2htxivUAuQuJ/30HiBvPLrZtVKaIKyRtuVKQ3Nm0QkqQsDnHN1Ah
CWW3H61tbpXNTGsIbQieDQaeMoC9s/WkDDNLdFTVn8YRlxX784e357zme1SoD+ZEht/li3
dOOamw6Ir+1XJkcOzI+awIQ5/+oWgDh0DbBPeKIqMTRV91P0iu97V/q8vTngjNz+74etN5
ezuwXfod5BU2xlbkHYww3m4k3HEXlz43/htCDevkIFiiPHmsqaHIZv5m40I3+QQ7DN9MZP
UEPICMjvHXQH4miI8EOnNZ5rSn2NyvxsZVZHw1O/6zWBEKmey/LfOHbdjwYbxG1oVdd7Bv
VbKD68imGVGkdCv8zpCIACCwguCakwE188VMirouxpXmx/IrfK3WhhbpCZXADjxLnauSaR
sNtEMMKEH8oNGLyK2tgYuvkaI0NxyS+isGX1rcZ/jeV0bTF8UB6UCYIn/JiTVr8ASQRP18
2dHkN/LwfB8NZ1biEIKt3TpmkoV90/M=
-----END OPENSSH PRIVATE KEY-----
You can use the following command:
ssh-keygen -p -f id_rsa
The command will first request the current password (in this case testing123
), and then prompt you to set a new one - if you simply press Enter without typing anything, the key will be saved without a password.
You can also provide the old and new passwords directly in the command line. Leaving the new password as empty quotes will remove it:
ssh-keygen -p -f id_rsa -N "" -P "testing123"
Here's what each option means:
-p
- change the password of a private key file.-f id_rsa
- the filename of the private key to update.-P "testing123"
- existing password.-N ""
- new password, left empty to remove.
Leave a Comment
Cancel reply