業務にて関係部署に公開鍵を渡す機会があることも、ないこともない!
しかし、公開錠のコメントを下のように私用のメールアドレスで作ってしまったそんなあなた!
.pub
ssh-rsa AAAAB3NzaC1yXXXXXXXXXXXXXXXXXXXXXXXXX== stbtkhr@sample.com
もっとわかりやすく鍵の中身を変えずに、コメントのみを会社のメルアドとかにしたい!
いろいろ調べたが検索してみても欲しいやつがなかった。
とりあえずコマンドには、manや!
man ssh-keygen
Too many arguments.
usage: ssh-keygen [-q] [-b bits] [-C comment] [-f output_keyfile] [-m format]
[-N new_passphrase] [-t dsa | ecdsa | ed25519 | rsa]
ssh-keygen -p [-f keyfile] [-m format] [-N new_passphrase]
[-P old_passphrase]
ssh-keygen -i [-f input_keyfile] [-m key_format]
ssh-keygen -e [-f input_keyfile] [-m key_format]
ssh-keygen -y [-f input_keyfile]
ssh-keygen -c [-C comment] [-f keyfile] [-P passphrase]
//以下省略
-C comment
Provides a new comment.
-c Requests changing the comment in the private and public key files. The program will prompt for the file containing the private keys, for the passphrase if the key has one, and for the new comment.
と書いてあったので、以下を実行してみる。
ssh-keygen -c -C "test"
これだけ。そうすると以下のように変わるはず。
.pub
ssh-rsa AAAAB3NzaC1yXXXXXXXXXXXXXXXXXXXXXXXXX== test
見事最後のコメント部分だけ変更になった。
vimで変更するのも考えたが、(ないと思うけど)破壊する恐れがあったので、ssh-keygenで行うのが安全かな?
ここまで至るまでmanをよく読まず適当に試した結果、今まで登録していた秘密鍵すら変更する失敗を犯しました。
そんな失敗をしないようにしましょうね!みなさま!