HPE CRAY 자료 공유

SSH 공개 key 생성 예제 본문

Applications/LINUX

SSH 공개 key 생성 예제

CRAY KOREA Blog 2021. 7. 23. 14:46

1. ssh-keygen 실행 예제

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/leesangy/.ssh/id_rsa): 
Created directory '/home/leesangy/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/leesangy/.ssh/id_rsa.
Your public key has been saved in /home/leesangy/.ssh/id_rsa.pub.
The key fingerprint is:
--- 생략 ---


2. ssh-copy-id 실행 예제

$ ssh-copy-id localhost
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/leesangy/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
leesangy@localhost's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'localhost'"
and check to make sure that only the key(s) you wanted were added.


3. 생성 확인

$ ls -l ~/.ssh
total 16
-rw------- 1 leesangy xxxx  398 Jul 23 00:34 authorized_keys
-rw------- 1 leesangy xxxx 1675 Jul 23 00:31 id_rsa
-rw-r--r-- 1 leesangy xxxx  398 Jul 23 00:31 id_rsa.pub
-rw-r--r-- 1 leesangy xxxx  171 Jul 23 00:33 known_hosts


4. 기타

$ cat .ssh/config 
StrictHostKeyChecking no