秘密鍵→ PEM 公開鍵
方法1
ssh-keygen を使う
ssh-keygen -y -f ~/.ssh/id_rsa -e -m PKCS8 > ~/.ssh/id_rsa.pub.pkcs8
方法2
openssl コマンドを使う
openssl rsa -in ~/.ssh/id_rsa -pubout -out ~/.ssh/id_rsa.pub.pem
openssl コマンドで使える公開鍵はPCKS8のPEM形式なのでどちらでも大丈夫.
どちらで作っても結果は同じ
takuya@rena:~/Desktop$ md5sum ~/.ssh/id_rsa* b5457f3dc56dfcc12b584c4d7ea6430a /Users/takuya/.ssh/id_rsa.pub.pem b5457f3dc56dfcc12b584c4d7ea6430a /Users/takuya/.ssh/id_rsa.pub.pkcs8
便利ですね。
ちなみに、openssh形式の場合は
ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub