1. Destination Server 에서 아래 명령어를 통해 인증 키 생성, 옵션을 통해 인증키의 인증방식을 수정 가능
[root@Destination Server ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
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:
SHA256:6MLun8gQLmRbAqPGH5XKw+WFX3wKdfGC8mm+ziyWyUs root@Destination Server.net
The key's randomart image is:
+---[RSA 2048]----+
| . o. |
| o o o . |
|o = + + o . |
|+.o = o.= + . |
|.*.B ...S= |
|+.=oo. o |
|..o.o oEo. |
| . + o.Bo . |
| .=.+.+= |
+----[SHA256]-----+
[root@Destination Server /]# cd ~/.ssh/
[root@Destination Server .ssh]# vi ./authorized_keys <- Source 서버에서 생성한 키를 삽입 할 목적
2. Source가 될 리눅스 서버에서 아래 명령어 수행
[root@Source Server /]# ssh-keygen
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:
5e:32:7c:5e:67:58:5c:31:7d:c0:19:20:83:4e:c2:88 root@Source Server
The key's randomart image is:
+--[ RSA 2048]----+
| . o .o .oo*+|
| E . o o o .o.+|
| + o .|
| .. o |
| S o o o |
| . * . o |
| . . |
| |
| |
+-----------------+
[root@Source Server /]# cat ~/.ssh/*pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmk5uEnZOcMC8OtWyyu/FLQmqyla5VbSo2yR1bRwgDP4zcxDkm3bvKZAmRbQYOKzOum++jOUZBliW141wXhV+LqGAvg2vYOa5y06Gfdlw6pJwVA8/1/H/BBPFCpYGShUJNMxw89Y/Ct3gcH1f0umcxzaJRvhzpu0z/FDmr3ZFyMT4oQ+4pHz6IgtFKiDCzQZJbmm5i9zLBoGGyRtNYaQyF46YB+u567hU1SIbMRofzaWFqePt6ty0XboPmIdcgPD0HEjLDCWTttXgPdprK54m7MZP2SMR3EGTKRMsSp48ssMrQompMkP2HXHTEI3wK/Bia7gmx+VB+CpyQRMsV/eQB root@Source Server
3. Source가 될 리눅스 서버에서 해당 인증키를 복사하여 Destination Server authorized_keys 에 등록
4. 접속 테스트
[root@Source Server /]# ssh 192.168.0.241
Last login: Mon Apr 3 21:34:01 KST 2017 on cron
Last login: Mon Apr 3 21:34:55 2017 from 192.168.0.242
[root@Destination Server ~]#
5. 원격 명령어 수행 테스트
[root@Source Server /]# ssh 192.168.0.241 free
total used free shared buffers cached
Mem: 4059404 3643352 416052 0 4752 423612
-/+ buffers/cache: 3214988 844416
Swap: 0 0 0
[root@Source Server /]#
[root@Source Server /]# ssh 192.168.0.241 hostname
Destination Server
'Operation System' 카테고리의 다른 글
Windows 2016 Active Directory(AD) 설치 (0) | 2019.01.14 |
---|---|
[Linux] 메모리 및 CPU 상태 확인 관련 명령어 (0) | 2017.04.18 |
[Linux] find, grep 명령어 활용 (0) | 2017.04.03 |