Recently i learned something really cool! since the public ssh key is part of the private ssh key we can extract the public key from the private; to do this we use the ssh-keygen
command vs the private key.
ssh-keygen -y -f ~/.ssh/id_rsa
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDkCGI5oGH0fqYelPZXIMTdcvXDlRxKzGey3UH4L7QmChi8sS9VY74qsgBwiE3rio/D0zTnR7Jdk63pFFg75ZjKakQEZK5iINqLNSj5tesST0W5/J6AaPRbUQhMZqiA1mhfUaVw15VtvRzle/ke9t+pWXNNkaWgvrSuNCP8v9/IAfBdQaoPy+7y7x9XSWR22XebxtFm55Rzk7p/HTdJHtVf6i+HtJFXYg06KcczyVZQTVq1bL2xWDtj4kX0F0XgdR96kI05cipYJbFqqjR9ksPjMV3JiLFcCXX6Bd1L0HJ4wW7bTwDzojuYqACr/JyAi4tX9Pz95wdk6SyJnC/QjbLtY8RddpWYilJpwJKWDJXdfc4fNxwOkVeSewaaVILpi11q+jvbqYcu+cAQ+dSmN+eKrfCGPypaWZSuGGkfgXjymVR+dhLY1WLBn4X5Q8= kpatronas@DESKTOP-B707TG6
Explaining the parameters
-y : This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.
-f: The filename of the key file.
So if we redirect the output of the previous command to a file we have the our public key…