Thursday, June 9, 2016

ssh-keygen: Generating Private and Public Keys (公開鍵と秘密鍵を作る)


Commands:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa): 
/Users/username/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xCFSgzCQb5J5yjX911Xvdav018XVmXbfibdoEYxjXs0


$ ls -l .ssh/
total 24
-rw-------  1 username  staff  1679 Jun  4  2014 id_rsa
-rw-r--r--  1 username  staff   394 Jun  4  2014 id_rsa.pub
-rw-r--r--  1 username  staff  1118 May 16 10:26 known_hosts


$ cat .ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAzTem0991UOAl1phQcdB+NvMsP0h8AEXPdb3P2fwhMV641G97
oVGh2+BBwpe/6V6SYMska+nRObJdhZRN4z1rmtqKGd7l6H+zZIitljD1Q6VmXihN
s8cpxIOcj8xNQLcMiSPmNeR27eFjRBIV7B7pwrvnpBn93d8Ou1QsRs/GgNU28Xus
zrN3vVVza4EFvfcnA+cbVwF4fMeSbfh4YAJmuT+/oENK0jCkmLMSmq+03EdZOcoP
bgtNrvDYKo7kA16KizvSPghsb9a3xcpep/H1JXJTxYH7Sc2CvSbsx8RJd8jBUh/4
s0r4mCqdDE6YdXR91FmuQ4iAH/G5Q5mVZDwpEwIDAQABAoIBAHDyXkliRYlbtLel
YTEjFTRdJk82L7less4UyB8rm4E2pveU3DBvY2xGwyq8po1k1Z+cbtFOAS+GMd7h
PvUAywaRnUyb12HdVvjQGOn+zB6NHAhamlmGFkDoRvUBJe8mUCnyrjOfKK3ITQAc
DCDG6tWY4eb5vzWsHMmRjET0+kXRFsdApPAqIfz0AXME0XtW6FmZ93uWkHb6ikf+
0hqEoh7vWQVDBlr9CixPIZYIlsncOGoSYgxoyW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N6bT33VQ4CXWmFBx0H428yw/SHwARc91vc/Z/CExXrjUb3uhUaHb4EHCl7/pXpJgyyRr6dE5sl2FlE3jPWua2ooZ3uXof7NkiK2WMPVDpWZeKE2zxynEg5yPw41AtwyxI+Y15Hbt4WNEEhXsHunCu+ekGf3d3w67VCxGz8aA1Tbxe6zOs3e9VXNrgQW99ycD5xtXAXh8x5Jt+HhgAma5P7+gQ0rSMKSYsxKxr7TcR1k5yg9uC02u8NgqjuQDXoqLO9I+CGxv1rfFyl6n8fUlclPFgftJzYK9JuzHxEl3yMFSH/izSviYKp0MTph1dH3UWa5DiIAf8blDmZVkPCkT OpenShift-Key


Vocabularies:
  • Public-key cryptography (公開鍵暗号)
  • Symmetric-key algorithm (共通鍵暗号)