์ฐธ๊ณ ์ฌ์ดํธ
โ Git - Git ์๋ฒ - SSH ๊ณต๊ฐํค ๋ง๋ค๊ธฐ
๐ SSH ๊ณต๊ฐํค
๋ก์ปฌ์์ ๋ณธ์ธ๋ง์ ๊ฐ๋ฐ์ ์ํด์๋ผ๋ฉด ์ ๊ฒ์๊ธ ์ฒ๋ผ SSH Key๊ฐ ์์ด๋ Git์ ์ด์ฉํ ์ ์๋ค.
๊ทธ๋ฌ๋ ์ธ๋ถ Git ์๋ฒ์ ์ฝ๋๋ฅผ ์ฌ์ฉํ๋ ค๋ฉด SSH ํ๋กํ ์ฝ์ ์ฌ์ฉํด์ผํ๋ค.
๋ง์ Git ์๋ฒ๋ค์ SSH ๊ณต๊ฐํค๋ก ์ธ์ฆํ๋ค.
๋ด ์ปดํจํฐ๊ฐ ์๋ ๋คํธ์ํฌ๋ก ๋ค๋ฅธ ์ปดํจํฐ์ ์ ๋ฌํด์ฃผ๊ณ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ์๋ณผ ์ ์๊ฒ ํด์ฃผ๋๊ฒ ๋ฐ๋ก SSH์ด๋ค.
๊ณต๊ฐํค๋ฅผ ๋ง๋๋ ๋ฐฉ๋ฒ์ ๋ชจ๋ ์ด์์ฒด์ ๊ฐ ๋น์ทํ๋ค.
๐ ๊ณต๊ฐํค ์์ฑ
์ฌ์ฉ์์ SSH ํค๋ค์ ๊ธฐ๋ณธ์ ์ผ๋ก ~/.ssh ๋๋ ํ ๋ฆฌ์ ์ ์ฅํ๋ค.
$cd ~/.ssh
$ls
id_dsa๋๋ id_rsa๋ผ๋ ํ์ผ์ ์ด๋ฆ์ด ๋ณด์ผ ๊ฒ์ด๊ณ ๊ฐ์ ํ์ผ๋ช ์ผ๋ก .pub์ด๋ผ๋ ํ์ฅ์๊ฐ ๋ถ์ ํ์ผ์ด ์์ ๊ฒ์ด๋ค.
๊ทธ ์ค, .pub ํ์ผ์ด ๊ณต๊ฐํค์ด๊ณ ๋ค๋ฅธ ํ์ผ์ ๊ฐ์ธํค์ด๋ค.
๋ง์ฝ ํค๊ฐ ์๋ค๋ฉด ์์ฑํ๊ณ , .ssh ํด๋๊ฐ ์๋ ๊ฒฝ์ฐ ssh-keygen์ด๋ผ๋ ํ๋ก๊ทธ๋จ์ผ๋ก ํค๋ฅผ ์์ฑํด์ผํ๋ค.
ssh-keygen์ Linux๋ Mac์ SSH ํจํค์ง์ ํฌํจ๋์ด ์๊ณ , Windows๋ 'Git for Windows' ์์ ๋ค์ด์๋ค.
$ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/maseunghyun/.ssh/id_rsa): key ์ด๋ฆ (default: id_rsa
Created directory '/path/to/.ssh'.
Enter passphrase (empty for no passphrase): key ๋น๋ฐ๋ฒํธ
Enter same passphrase again: key ๋น๋ฐ๋ฒํธ ์ฌ์
๋ ฅ
Your identification has been saved in /path/to/.ssh/id_rsa.
Your public key has been saved in /path/to/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RANDOMRANDOMRANDOMRANDOMRANDOMRANDOMRANDOMRANDOMRANDOM email@random.com
The key's randomart image is:
+----[RSA 256]----+
| ..--o |
|. +-*.= |
| ...---=o |
| . ------. |
|.o .o +-=. .. .|
|+ - -+ --.. E o|
| . . .---. o |
|. .+ |
| .E.. |
+----[SHA256]-----+
ํค๊ฐ ์์ฑ๋์์ผ๋ฉฐ ls๋ฅผ ํตํด ๋ชฉ๋ก์ ํ์ธํ๋ค.
๊ทธ ํ cat ๋ช ๋ น์ด๋ฅผ ํตํด .pub ํ์ฅ์๋ฅผ ๊ฐ์ง ๊ณต๊ฐํค์ ๋ด์ฉ์ ์ถ๋ ฅํ์ฌ ssh-rsa๋ถํฐ ๋๊น์ง ๋ณต์ฌํ๋ค.
$ls
id_rsa
id_rsa.pub
$cat id_rsa.pub
ssh-rsa BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
BlahBlahBlahBlahBlahBlahBlahBlahBlahBlahBlah
๐ ๊ณต๊ฐํค ๋ฑ๋ก
GitHub ์ฐ์ธก ์๋จ์ ํ๋กํ์ ๋๋ฌ Settings์ ๋ค์ด๊ฐ๋ค.
์ข์ธก ์ฌ์ด๋ ๋ฉ๋ด์ SSH and GPG keys๋ฅผ ๋ค์ด๊ฐ๋ค.
์ฐ์ธก์ New SSH key ๋ฅผ ๋๋ฌ์
- Title: ์ฌ์ฉ์๊ฐ ์ํ๋ ํค ์ด๋ฆ ์์ฑ
- Key: cat์ผ๋ก .pub ๋ด์ฉ์ ๋ณต์ฌํ ๊ณต๊ฐํค ๋ด์ฉ์ ์์ฑ
์ด๋ ๊ฒ ํ๋ฉด SSH Key๊ฐ ๋ฑ๋ก๋๋ค.
๊ฐ์ธํค์ .๊ณต๊ฐํค(.pub)๊ฐ ๋์์ ๋์ค๋ ์ด์ ๋ ๊ณต๊ฐํค๋ ์ธ๋ถ์ ๋ ธ์ถ๋์ด๋ ์๊ด ์์ด ์ธ๋ถ ์ปดํจํฐ์๊ฒ ๋ฑ๋กํด๋๊ณ , ์ฐ๊ฒฐ ์์ฒญ ์, SSH ์๋ฒ์์๋ ์๋ฒ์ ๋ฑ๋ก๋ ํค์ ๊ฐ์ธํค์ ์ ๋ณด๋ฅผ ๋น๊ตํ์ฌ ์ธ์ฆํฉ๋๋ค.
'DevOps > GitHub' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ GitHub ] ์๊ฒฉ ์ ์ฅ์ ํ๋ก์ ํธ ๋ฒ์ ๊ด๋ฆฌํ๊ธฐ (0) | 2024.04.11 |
---|---|
[ GitHub ] Repository ์๊ฒฉ ์ ์ฅ์ ์ด์ฉํด๋ณด์. (0) | 2024.04.11 |
[ GitHub ] Git / GitHub ์ฐจ์ด ๋ฐ ์ดํดํ๊ธฐ (0) | 2024.02.22 |