Generate ssh public key from private key on command line

In case you have lost your ssh public key, you can re-generate it from the private key you have. Here is the command to generate public key from private rsa key using ssh-keygen utility.

ssh-keygen-man-y-option-section

$ ssh-keygen -y -f private.key
ssh-rsa AAAAB3NzaC1yc2EAABADARABAAABAQDH4ZWhgBnDmEJfqTT/I9/2GFLXmvhqvA0PoF7I2iFk6Ph+3zQXNollZ4XKGqtKNBbDRtQsODjOQz6eQfHslRg0g217xt+CGY+1vT2HMuOjPxG/LX0KlL2c1B/xSSFpPxfDU1i/aG0sfYYwoFLIg/fCELBGDo4XGD1QSt86xaLhg1jpw6PSOFG8Dn/gEh7CsFEO09/z4ABHpI0/xPzJh5xjL8/+QOKYGpY5yMxnIk+6+zaVS9LLftS55xgSoBvJOOm11FvX7A5VGrOAtSlq+4j7oyu4t+SK7vKoTrhUjWg+xEAnl0V3/B5YtY4Ue5ia5glUZRIOYWOcKsm2rT/adv9Z

Note that this may not have the key label part (3rd colum) in public key. Ssh public key will work without label string.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments