40
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

sshの公開鍵のフォーマット変更

Posted at

なんかよく知らない形式の鍵をもらってどうしたもんかと思って調べた。
ssh-keygenのメモ。

ssh-keygenで鍵のフォーマットの変更をする

##test_rsa.pub中身

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDK4MEG2EklU6k3OtRaVlJC2ytd3rRIyuQ3HzBCHU8rNDDyal2Tdmmt0oJGFAgYBcsgG/DwcGElM9yGxMQaertKyv6kpus//l7N3/r5eQO2efi9eaikVDZ+GC3aN+AjgVVT4t8ZkWyyi8/UimgaO8lqC0IQK0L5Ez+dGdbLrvqnbemCAf3rkHnX/BkAEGLY7jm9ZT6o5SShHC9QcC9V4mTOrg9ZChJsLdr3FbsUJqraw5gEN4AqqgHzADngoggywH7dBlrLk6JZmYUVVE0XKeYCIUGiPchyiXS/s+0xLZi4kqM4/YkJDTuc2krf8q6UEhIeR6UWWJsSr/1MYHeD29z/ kyagi@katsumi-no-MacBook-Pro.local

この公開鍵を

ssh-keygen -f test_rsa.pub -e -m pem

こうすると

-----BEGIN RSA PUBLIC KEY-----
MIIBCgKCAQEAyuDBBthJJVOpNzrUWlZSQtsrXd60SMrkNx8wQh1PKzQw8mpdk3Zp
rdKCRhQIGAXLIBvw8HBhJTPchsTEGnq7Ssr+pKbrP/5ezd/6+XkDtnn4vXmopFQ2
fhgt2jfgI4FVU+LfGZFssovP1IpoGjvJagtCECtC+RM/nRnWy676p23pggH965B5
1/wZABBi2O45vWU+qOUkoRwvUHAvVeJkzq4PWQoSbC3a9xW7FCaq2sOYBDeAKqoB
8wA54KIIMsB+3QZay5OiWZmFFVRNFynmAiFBoj3Icol0v7PtMS2YuJKjOP2JCQ07
nNpK3/KulBISHkelFlibEq/9TGB3g9vc/wIDAQAB
-----END RSA PUBLIC KEY-----

こうなる。
ぎゃくにする場合は、

ssh-keygen -i -f filename

とすれば、デフォルトのフォーマットのrsaに変換できる。
ssh-keygenの-mオプションで指定できるのは

  • rfc4716(rsa)
  • pkcs8
  • pem

で、デフォルトはrsaになっている。

40
26
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
40
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?