SSH KEY 원격지서버에 복사하기



원격지 서버에 암호입력 없이 접속하기 위해서는 SSH KEY 를 생성해서 원격지 서버에 복사해 두어야 한다.


ssh-keygen 과 ssh-copy-id 명령어를 이용해보자.


[root@conoha-jp ~]# 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:

3d:ec:1e:82:64:8a:6a:98:66:ce:5d:60:73:26:05:6e root@conoha-jp

The key's randomart image is:

+--[ RSA 2048]----+

|   .             |

|  . .            |

|   E .           |

|  . .    o       |

|   = oo S +      |

|  ..*+ . . .     |

|... ... . o      |

|+=. .    o .     |

|*o .      .      |

+-----------------+


옵션 생략하고 ssh-keygen 으로 하여도 된다.


생성된 키를 원격지 서버에 복사해보자.


[root@conoha-jp ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.1.3

The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established.

ECDSA key fingerprint is 68:03:15:9f:4a:96:27:6a:d0:26:9d:91:2e:f9:e2:ea.

Are you sure you want to continue connecting (yes/no)? yes

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@192.168.1.3's password:


Number of key(s) added: 1


Now try logging into the machine, with:   "ssh 'root@192.168.1.3'"

and check to make sure that only the key(s) you wanted were added.


옵션 없이 ssh-copy-id root@192.168.1.3 으로 하여도 된다.


ssh 포트가 22번이 아니라면 -p 옵션을 사용하면 된다.


예) ssh-copy-id -p포트번호 root@192.168.1.3



192.168.1.3 서버에 복사가 되었다.


이제 부터는 암호 입력없이 접속이 가능할 것이다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,