sshキー生成

提供: Wikiducca
移動: 案内検索

忘れるのでメモ。

[root@server ~]# su - hogeo
[hogeo@server ~]$ pwd
/home/hogeo
[hogeo@server ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hogeo/.ssh/id_rsa):
Created directory '/home/hogeo/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hogeo/.ssh/id_rsa.
Your public key has been saved in /home/hogeo/.ssh/id_rsa.pub.
The key fingerprint is:
ab:c1:d2:3e:45:67:8f:9g:h0:i1:12:jk:34:l5:67:89 hogeo@server.localhost
[hogeo@server ~]$

[hogeo@server ~]$ cd .ssh/
[hogeo@server .ssh]$ ls -l
合計 8
-rw-------  1 hogeo staff 951  4月  4 14:23 id_rsa
-rw-r--r--  1 hogeo staff 231  4月  4 14:23 id_rsa.pub

[hogeo@server .ssh]$ mv id_rsa.pub authorized_keys

[hogeo@server .ssh]$ chmod 600 authorized_keys
[hogeo@server .ssh]$
[hogeo@server .ssh]$ ls -la
合計 16
drwx------  2 hogeo staff 4096  4月  4 14:24 .
drwx------  4 hogeo staff 4096  4月  4 14:23 ..
-rw-------  1 hogeo staff  231  4月  4 14:23 authorized_keys
-rw-------  1 hogeo staff  951  4月  4 14:23 id_rsa
[hogeo@server .ssh]$

id_rsa をローカルに落とす。


[メモ] su せず、 root で生成する場合

nologin ユーザの sftp 用に必要なとき 等。

[root@server ~]# ssh-keygen -C hogeo@server.localhost


以上。