Unix/OpenSSH

ssh-keygen

秘密鍵の作り方

# 新方式

$ ssh-keygen -t rsa -f id_rsa
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase)
Enter same passphrase again:
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
...

# 旧方式

$ ssh-keygen -t rsa -m PEM -f id_rsa
...

公開鍵の作り方

# RFC4716/SSH2形式

$ ssh-keygen -e [-m rfc4716] -f id_rsa       
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "1024-bit RSA, converted by user@slackware.local from OpenSSH"
AAAAB3N..........................
........
---- END SSH2 PUBLIC KEY ----

# PEM PKCS8形式

$ ssh-keygen -e -m pkcs8 -f id_rsa           
-----BEGIN PUBLIC KEY-----
MIGdMA0..........................
........
-----END PUBLIC KEY-----

# PEM形式

$ ssh-keygen -e -m PEM -f id_rsa
-----BEGIN RSA PUBLIC KEY-----
MIGHAoG.........................
..........
-----END RSA PUBLIC KEY-----

# OpenSSH(authorized_keys)形式

$ ssh-keygen -i -f <(ssh-keygen -e -f id_rsa)
ssh-rsa AAAAB3Nz....................



---
update at 2020/01/27 23:04:58

※注:当サイトは特定環境において確認できた事象のみを記述しています。他の環境での動作は一切保証しません。