1.클라이언트에서 ssh-keygen을 실행해 SSH 키 페어를 만든다.
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):
Your identification has been saved in /home/username/.ssh/id_rsa.
Your public key has been saved in /home/username/.ssh/id_rsa.pub.
The key fingerprint is:
a9:49:2e:2a:5e:33:3e:a9:de:4e:77:11:58:b6:90:26 username@remote_host
The key’s randomart image is:
+–[ RSA 2048]—-+
| ..o |
| E o= . |
| o. o |
| .. |
| ..S |
| o o. |
| =o.+. |
|. =++.. |
|o=++. |
+—————–+
2.서버에 public 키를 카피하기
$ ssh-copy-id devpub@linuxsrv.com
The authenticity of host ‘foo.bar.com (111.111.11.111)’ can’t be established.ECDSA key fingerprint is fd:fd:d4:f9:77:fe:73:84:e1:55:00:ad:d6:6d:22:fe.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 keystest@foo.bar.com’s password:
Number of key(s) added: 1
Now try logging into the machine, with: “ssh ‘test@foo.bar.com'”and check to make sure that only the key(s) you wanted were added.