SSH Key
- SSH(Secure Shell Protocol)๋ ๋ณด์์ ์ผ๋ก ์์ ํ ํต์ ์ ์ํ ํ๋กํ ์ฝ.
- ssh ํต์ ์ ์ํด์๋ ๋น๋์นญ ํค๊ฐ ํ์ํ๋ค.
- Private key
- Public key
ssh-keygen์ผ๋ก ํค๋ฅผ ์์ฑํ๋ค.$ ssh-keygen # RSA ์ํธํ, ~/.ssh ๋๋ ํ ๋ฆฌ์ id_rsa, id_rsa.pub ํ์ผ์ด ๋ง๋ค์ด์ง๋ค. $ ssh-keygen -f ./ssh/key # RSA ์ํธํ, ./ssh ๋๋ ํ ๋ฆฌ์ key, key.pub ํ์ผ์ด ๋ง๋ค์ด์ง๋ค.id_rsa๋ ๋น๊ณต๊ฐ ํค์ด๋ฏ๋ก ์ ๋ ๊ณต๊ฐ๋์ด์๋ ์ ๋๋ค.id_rsa.pub์ ๊ณต๊ฐ ํค๋ค.
ssh-keyscan์ผ๋ก ๋ค๋ฅธ ์ปดํจํฐ(๋ณดํต ์๋ฒ)์ ๊ณต๊ฐ ํค๋ฅผ ๊ฐ์ ธ์จ๋ค.$ ssh-keyscan 192.168.43.39 # 192.168.43.39์ ๊ณต๊ฐ ํค๋ฅผ ๊ฐ์ ธ์จ๋ค. $ ssh-keyscan github.com >> ~/.ssh/known_hosts # github.com์ ๊ณต๊ฐ ํค๊ฐ ~/.ssh/known_hosts์ ์ถ๊ฐ๋๋ค.known_hosts์ ํค๋ฅผ ์ถ๊ฐํ๋ฉด ์ ์ํ ๋ ๋ฌผ์ด๋ณด์ง ์๋๋ค.
Troubleshooting
- public key๋ฅผ ์์ด๋ฒ๋ฆฐ ๊ฒฝ์ฐ:
$ ssh-keygen -y -f ~/.ssh/id_rsa # `-y` ์ต์ ์ ์ฃผ๋ฉด private ํค๋ก๋ถํฐ public ํค๋ฅผ ๋ค์ ์์ฑํ๋ค.