2008.06.25 00:25
1. 클라이언트에서 ssh-keygen 명령으로 ssh-key를 생성한다.
- ssh-keygen -t rsa 명령으로 ssh key를 생성한다. key를 생성하면, 홈 디렉토리내의 .ssh 디렉토리에 id_rsa, id_rsa.pub 두개의 파일이 생성된다.
[root@localhost root]# cd /root/.ssh/
[root@localhost .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b5:69:64:dd:16:70:b9:6d:b7:2f:36:da:39:ba:b0:e3 root@localhost
[root@localhost .ssh]# ls
id_rsa id_rsa.pub known_hosts
2. 생성된 key를 서버에 복사하기
- 생성된 id_rsa.pub 파일을 서버에 복사한다. 서버에 복사할 때는 접속하려는 계정의 홈 디렉토리 내에 .ssh/authorized_keys라는 파일 명으로 복사해 넣는다. 만약 여러대의 클라이언트에서 서버에 패스워드 없이 접속을 하기 위해서는, 각각의 클라이언트에서 key를 생성하고, id_rsa.pub 파일의 내용을 서버의 authorized_keys 파일에 추가해서 붙여 넣으면 된다.
[root@localhost .ssh]# scp id_rsa.pub 10.30.100.32:/root/.ssh/authorized_keys
The authenticity of host '10.30.100.32 (10.30.100.32)' can't be established.
RSA key fingerprint is 76:fa:84:e5:f9:de:46:18:56:7c:87:5f:c0:11:21:e5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.30.100.32' (RSA) to the list of known hosts.
root@10.30.100.32's password:
id_rsa.pub 100% |***************************************************************************| 224 00:00
3. 패스워드 없이 서버에 접속 테스트를 한다.
[root@localhost .ssh]# ssh 10.30.100.32
Last login: Tue Jun 24 14:40:23 2008 from 10.30.100.118
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:FC:69:5F:F0
inet addr:10.30.100.32 Bcast:10.30.101.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5668 errors:0 dropped:0 overruns:0 frame:0
TX packets:2536 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:549777 (536.8 KiB) TX bytes:297273 (290.3 KiB)
Interrupt:16 Base address:0xcc00
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@localhost ~]#
- 만약 접속이 불가능 하다면, 서버의 sshd_config(/etc/ssh/sshd_config) 파일에서 아래의 사항을 확인한다. 주석처리가 되어 있을 경우 주석을 제거하고 ssh데몬을 재시작 한 후에 접속 테스트를 한다.
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
26 | tcpdump 기본 사용 | sylee | 2008.07.02 | 39640 |
25 | VSFTP 에서 사용하는 port를 변경하기 | 호스트웨이 | 2012.03.23 | 39687 |
24 | 특정 계정만 su 명령어 사용 | 호스트웨이 | 2012.05.05 | 39702 |
23 | openssl 간단 사용법 | 호스트웨이 | 2008.12.10 | 41111 |
22 | 리눅스 Sleep 명령어 | 호스트웨이 | 2012.08.10 | 42138 |
21 | 터미널 창으로 메시지 보내기 | 호스트웨이 | 2008.05.19 | 44191 |
» | ssh-key를 생성하여 서버에 패스워드 없이 접속하는 방법 | jook | 2008.06.25 | 44751 |
19 | Kernel Parameters | HOSTWAY | 2008.06.04 | 45455 |
18 | /bin/false, /sbin/nologin 의 차이점 | 호스트웨이 | 2012.08.10 | 45638 |
17 | 시스템 시간 확인 및 동기화 하기 | sylee | 2008.05.15 | 46973 |
16 | history 조회시 '날짜,시간' 표시하기 | 호스트웨이 | 2012.03.16 | 49290 |
15 | xinetd 소개 및 설정 | 호스트웨이 | 2012.06.29 | 51903 |
14 | top 명령어 및 옵션 설명 | 호스트웨이 | 2012.03.27 | 52528 |
13 | 강제 umount 방법 (umount : device is busy 발생시) | 호스트웨이 | 2012.11.30 | 55424 |
12 | fdisk 명령어를 이용하여 수동으로 파티션 나누기 | 호스트웨이 | 2015.11.30 | 57674 |
11 | 서비스 이름으로 포트 번호 확인하기 | 호스트웨이 | 2012.04.13 | 57714 |
10 | 비대해진 로그 파일 내용을 비우는 방법 - /dev/null | 호스트웨이 | 2012.03.16 | 61402 |
9 | head 와 tail 사용하기 | sylee | 2008.05.14 | 63472 |
8 | 국가명 약어 (국가코드) | 호스트웨이 | 2012.04.13 | 64960 |
7 | Swap 메모리 늘리기 | 호스트웨이 | 2012.03.30 | 67200 |