何度もやるので備忘録 sshd 鍵認証設定 by centos

1.rootにて

>adduser 追加ユーザ名
>passwd 追加ユーザ名

>su - 追加ユーザ名

2.追加したユーザにて

>ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/追加したユーザ/.ssh/id_rsa): Enter押す
Created directory '/home/追加したユーザ/.ssh'.
Enter passphrase (empty for no passphrase):   パスワード入力 *1
Enter same passphrase again:            パスワード再入力
Your identification has been saved in /home/追加したユーザ/.ssh/id_rsa.
Your public key has been saved in /home/追加したユーザ/.ssh/id_rsa.pub.

>mv ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
>chmod 600 ~/.ssh/authorized_keys
>exit

3.クライアント端末より
winscpなどで、/home/追加したユーザ/.ssh/id_rsa をクライアントにダウンロード


4.rootにて
>vi /etc/ssh/sshd_config

SyslogFacility AUTHPRIV
LogLevel INFO
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no

>/etc/init.d/sshd restart

5.クライアント端末より
ユーザ名:追加ユーザ名
パスワード:*1で入力した物
鍵:id_rsa