Skip to main content

ssh 패스워드 없이 로그인 하기

client장비에서 sshkey 생성

 $> 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/
 The key fingerprint is:
 SHA256:123123 root@client
 The key's randomart image is:
 +---[RSA 2048]----+
 |                 |
 |         . .     |
 |        . =      |
 |       . +.+     |
 |        S.o=o. . |
 |          o= + .| |        .+.o=o+o|
 |       .oo=oB*+oE|
 |        o==B+o+==|

2. server 1~3까지 ssh 키 복사

$> ssh-copy-id
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/"
 The authenticity of host ' (' can't be established.
 ECDSA key fingerprint is SHA256:123412ss.
 ECDSA key fingerprint is MD5:01:15:23:36:78:47:11:ca:19:7a:20:30:e7:41:77:b2.
 Are you sure you want to continue connecting (yes/no)? yes #최초접속의 경우 yes 입력
 /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
 root@'s password: #server장비의 root패스워드 입력
Number of key(s) added: 1
 Now try logging into the machine, with:   "ssh 'root@'"
 and check to make sure that only the key(s) you wanted were added.