'ssh-keygen'에 해당되는 글 1건

  1. 2008.06.30 linux - 공개키에 의한 인증
2008. 6. 30. 00:39

linux - 공개키에 의한 인증

pki-login(Public Key infrastrucute - login : 공개키 기반)
:
password 입력 없이 원격 시스템에 접속할때 사용
로그인 하려고 하는 서버에 공개키를 전송해야 한다.
공개키를 만들기 우해선 openssh로부터 공인키와 개인키를 받아야 한다.
먼저      fedora에서 centos로 ssh로 접속해 공인키와 개인키를 받은 것을 확인하자.

[fedora]
[root@fedora ~]# ssh user01@192.168.10.30
The authenticity of host '192.168.10.30 (192.168.10.30)' can't be established.
RSA key fingerprint is 9b:e8:94:91:ed:5c:d3:4a:cb:9d:70:6a:d3:d7:e1:dc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.30' (RSA) to the list of known hosts.
user01@192.168.10.30's password:


처음 접속시 public key를 받아 온다
[root@fedora ~]# ls -a
.              .dmrc              .lesshst          anaconda-ks.cfg
..             .eggcups           .metacity         bbb.lst
.ICEauthority  .esd_auth          .mozilla          ftp.sniff
.Trash         .gconf             .nautilus         install.log
.Xauthority    .gconfd            .redhat           install.log.syslog
.bash_history  .gnome             .scim             nero.md5
.bash_logout   .gnome2            .serverauth.2576  nero.tar.gz
.bash_profile  .gnome2_private    .ssh              scsrun.log
.bashrc        .gstreamer-0.10    .tcshrc
.cshrc         .gtkrc-1.2-gnome2  Desktop
[root@fedora ~]# cd .ssh
[root@fedora .ssh]# ls
known_hosts                       // centos에서 받아온 public key
[root@fedora .ssh]# cd /etc/ssh
[root@fedora ssh]# ls -l
합계 200
-rw------- 1 root root 132839 11월 10  2007 moduli
-rw-r--r-- 1 root root   1827 11월 10  2007 ssh_config
-rw------- 1 root root    668  6월 19 07:43 ssh_host_dsa_key
-rw-r--r-- 1 root root    590  6월 19 07:43 ssh_host_dsa_key.pub
-rw------- 1 root root    963  6월 19 07:43 ssh_host_key
-rw-r--r-- 1 root root    627  6월 19 07:43 ssh_host_key.pub
-rw------- 1 root root   1675  6월 19 07:43 ssh_host_rsa_key
-rw-r--r-- 1 root root    382  6월 19 07:43 ssh_host_rsa_key.pub
-rw------- 1 root root   3300  6월 19 08:13 sshd_config

[root@fedora ssh]# cat ssh_host_rsa_key.pub     // 자신에게 접속할시 나눠주는 pub key
ssh-rsa
AAAA~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[root@fedora ssh]# su - test01
[test01@fedora ~]$ ssh-keygen -t rsa       // 공개키 생성
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test01/.ssh/id_rsa):   엔터
Created directory '/home/test01/.ssh'.
Enter passphrase (empty for no passphrase):   엔터
Enter same passphrase again: 엔터
Your identification has been saved in /home/test01/.ssh/id_rsa.
Your public key has been saved in /home/test01/.ssh/id_rsa.pub.
The key fingerprint is:
e6:81:da:5f:5d:4a:c1:b3:44:bc:8b:14:bb:db:c9:c7 test01@fedora.linux.com
[test01@fedora ~]$ cd .ssh
[test01@fedora .ssh]$ ls
id_rsa  id_rsa.pub                              // 공개키와 사설키 생성 되었따.
[test01@fedora .ssh]$ scp id_rsa.pub user01@192.168.10.30:         // 공개키를 보내자
The authenticity of host '192.168.10.30 (192.168.10.30)' can't be established.
RSA key fingerprint is 9b:e8:94:91:ed:5c:d3:4a:cb:9d:70:6a:d3:d7:e1:dc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.30' (RSA) to the list of known hosts.
user01@192.168.10.30's password:
id_rsa.pub                                    100%  405     0.4KB/s   00:00   
[test01@fedora .ssh]$

[centos]
[root@centos ~]# su - user01
[user01@centos ~]$ ls
id_rsa.pub
[user01@centos ~]$ mkdir .ssh
[user01@centos ~]$ mv id_rsa.pub .ssh/authorized_keys
[user01@centos ~]$ ls -l .ssh
합계 4
-rw-r--r-- 1 user01 user01 405  6월 29 17:37 authorized_keys
[user01@centos ~]$ chmod 700 .ssh/                    // 실행 권한 줌
[fedora]
[test01@fedora .ssh]$ ssh user01@192.168.10.30
Last login: Sun Jun 29 17:38:43 2008 from 192.168.10.10        // 패스워드 없이 바로 로긴 되었다.
[user01@centos ~]$