ํ’€์Šคํƒ ์›น๐ŸŒ ๊ฐœ๋ฐœ์ž ์ง€๋ง์ƒ ๐Ÿง‘๐Ÿฝโ€๐Ÿ’ป
โž• ์ธ๊ณต์ง€๋Šฅ ๊ด€์‹ฌ ๐Ÿค–


Categories


Recent views

  • 1
  • 2
  • 3
  • 4
  • 5

git deploy key ์‚ฌ์šฉํ•˜๊ธฐ

GIT Clone by deploy key

๊ฐ ์„œ๋ฒ„๋งˆ๋‹ค GIT์˜ ์œ ์ €๋ช…๊ณผ ํŒจ์Šค์›Œ๋“œ๋ฅผ ์„ค์ •ํ•˜๋ฉด, ๋ฒˆ๊ฑฐ๋กœ์šธ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋ณด์•ˆ์ƒ์œผ๋กœ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋‹ค.

ssh-keygen -t ed25519 -C "USERNAME@EMAIL.com"

  • -t : ์‚ฌ์šฉํ•  ์•Œ๊ณ ๋ฆฌ์ฆ˜, ed25519๊ฐ€ ์ผ๋ฐ˜์ ์ด๊ณ  ์•ˆ์ „ํ•˜๋‹ค.

  • -C: ํ‚ค ๋งˆ์ง€๋ง‰์— ์ž์‹ ์˜ ์ด๋ฉ”์ผ์„ ์‚ฝ์ž…ํ•˜์—ฌ ์ปค๋งจํŒ…

๋‚˜์˜ค๋Š” ์„ค์ •์€ ํŒŒ์ผ ์„ค์ •, passphrase์ด๋ฉฐ, ๊ธฐ๋ณธ ์„ค์ •๋„ ๊ดœ์ฐฎ๋‹ค.

touch ~/.ssh/config 
chmod 600 ~/.ssh/config 
vim ~/.ssh/config 

.ssh ํด๋”์— config ํŒŒ์ผ์„ ๋งŒ๋“ค๊ณ , ๊ถŒํ•œ์„ ๋ฐ”๊พผ ๋’ค vim์„ ์ด์šฉํ•ด ์•„๋ž˜์™€ ๊ฐ™์€ ์„ค์ •์„ ๋„ฃ๋Š”๋‹ค.

Host github-YOUR-APP 
    HostName github.com 
    AddKeysToAgent yes 
    PreferredAuthentications publickey 
    IdentityFile ~/.ssh/id_ed25519

์ด๋Š” EC2 ๊ธ€์—์„œ ๋ณธ ์  ์žˆ์„ ๊ฒƒ์ด๋‹ค.

cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILs35pzG5jZakTEHDWeRErgkAmabhQj2yj/onxlIQgli user@example.com

cat ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ๋œ ํ‚ค๋ฅผ ๋ณต์‚ฌํ•˜๊ณ  ์ด๋ฅผ ๋Œ€์ƒ GIT repository -> Settings -> Deploy keys -> Add deploy key์— ํ‚ค ์ด๋ฆ„๊ณผ ํ‚ค๋ฅผ ์ €์žฅํ•œ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ๋“ฑ๋ก๋œ๋‹ค.

์ดํ›„ ์•„๋ž˜์™€ ๊ฐ™์ด SSH๋ฅผ ํ†ตํ•ด์„œ Clone์„ ํ•  ์ˆ˜ ์žˆ๋‹ค.

[ec2-user@ip-xxx-xxx-xxx-xxx docker-server]$ git clone git@github.com:RoadVirusHN/Movi-Dick.git
Cloning into 'Movi-Dick'...