๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๋นˆ ๊ตฌ๋ฉ ์ฑ„์šฐ๊ธฐ

[GitLab] SSH ํ‚ค ๋“ฑ๋กํ•˜๊ธฐ

์ฐธ๊ณ  ๋งํฌ

https://developerbee.tistory.com/241

 

[Gitlab] ssh key ์ƒ์„ฑ ๋ฐ ๋“ฑ๋ก

์ƒˆ๋กœ์šด ํšŒ์‚ฌ์—์„œ GitLab์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜์–ด(์ด์ „ ํšŒ์‚ฌ์—์„œ๋„ ์ž ๊น ์ผ์ง€๋งŒ...) ssh key๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ๋“ฑ๋กํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•ด๋ณด๋ ค ํ•ฉ๋‹ˆ๋‹ค. 1. ssh ํ‚ค ์ƒ์„ฑ ๋จผ์ € ๋ฃจํŠธ์˜ .ssh ํด๋”๋กœ ์ด๋™ํ•ด์„œ(์—†๋‹ค๋ฉด

developerbee.tistory.com

https://docs.gitlab.com/ee/user/ssh.html#see-if-you-have-an-existing-ssh-key-pair

 

Use SSH keys to communicate with GitLab | GitLab

Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.

docs.gitlab.com

https://docs.gitlab.com/ee/user/ssh.html#generate-an-ssh-key-pair

 

Use SSH keys to communicate with GitLab | GitLab

Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.

docs.gitlab.com

https://docs.github.com/ko/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys

 

๊ธฐ์กด SSH ํ‚ค ํ™•์ธ - GitHub Docs

SSH ํ‚ค๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์ „์— ๊ธฐ์กด SSH ํ‚ค๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

docs.github.com

 

 

๊ทธ๋ฃน ์ƒ์„ฑ ์™„๋ฃŒ ํ›„, ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ๊นŒ์ง€ ์™„๋ฃŒํ–ˆ๋‹ค.

 

SSH ํ‚ค๋ฅผ ๋“ฑ๋กํ•ด์•ผ ํ•œ๋‹ค๊ณ  ์•Œ๋ฆฐ๋‹ค.

์ •์ƒ์ ์ธ push, pull ์‚ฌ์šฉ์„ ์œ„ํ•ด์„œ๋Š” SSH ํ‚ค๋ฅผ ๋“ฑ๋กํ•ด์•ผ ํ•œ๋‹ค.

 

1) ๋‚ด PC์— ์ด๋ฏธ SSH ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ.

 

GitHub ๋ฌธ์„œ์—์„œ ์•Œ๋ ค์ค€ Git Bash ๋ช…๋ น์–ด

$ ls -al ~/.ssh
# .ssh ๋””๋ ‰ํ† ๋ฆฌ ์•ˆ์— ํŒŒ์ผ ์กด์žฌ ์‹œ ํŒŒ์ผ๋“ค์˜ ๋ชฉ๋ก์„ ๋ณด์—ฌ์ค€๋‹ค.

GitLab ๋ฌธ์„œ์—์„œ๋Š” ํ™ˆ ๋””๋ ‰ํ† ๋ฆฌ์˜ .ssh ์„œ๋ธŒ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๋ผ๊ณ  ํ•œ๋‹ค. ์ด ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์—†๋‹ค๋ฉด ๋‹ค๋ฅธ ๊ณณ์— ์œ„์น˜ํ•˜๊ฑฐ๋‚˜ .ssh ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์—†๋Š” ๊ฒƒ์ด๋ผ๊ณ  ํ•œ๋‹ค. GitHub ๋ฌธ์„œ์—์„œ ์•Œ๋ ค์ค€ ํ™•์ธ ๋ฐฉ๋ฒ•๊ณผ ๋งฅ๋ฝ์€ ๋™์ผํ•œ ๋“ฏ ํ•˜๋‹ค.

 

๋‚ด PC์—๋Š” SSH ํ‚ค๊ฐ€ ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค.

 

2) SSH ํ‚ค ์ƒ์„ฑํ•˜๊ธฐ

 

๋ช…๋ น์–ด ๊ตฌ์กฐ

ssh-keygen -t {์•Œ๊ณ ๋ฆฌ์ฆ˜} -C {์ฝ”๋ฉ˜ํŠธ}

 

ssh-keygen -t ๋กœ SSH ํ‚ค๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๋ช…๋ น์–ด๋ฅผ ์“ฐ๊ณ , ๋‚˜๋Š” ์–ด๋–ค ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์จ์•ผํ• ์ง€, ์ฝ”๋ฉ˜ํŠธ๋ฅผ ์–ด๋–ค ๊ฒƒ์„ ๋„ฃ์–ด์•ผ ํ•˜๋Š”์ง€ ์„ ํƒํ•ด์•ผ ํ•˜๋‚˜๋ณด๋‹ค.

 

์ฒ˜์Œ์—๋Š” SSH ํ‚ค ์ƒ์„ฑ ๊ด€๋ จ ์—ฌ๋Ÿฌ ํฌ์ŠคํŠธ๋“ค์„ ๋ณด๊ณ , ๊ณตํ†ต์ ์œผ๋กœ ๋ช…๋ น์–ด์— ์ด๋ฉ”์ผ ๊ฐ’์„ ์ž…๋ ฅํ•˜๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค. ์™œ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด์•ผ ํ•˜๋Š”์ง€๋Š” ์„ค๋ช…์ด ์—†์–ด์„œ ์ฐœ์ฐœํ–ˆ๋Š”๋ฐ, GitLab ๋ฌธ์„œ์—์„œ ํ•ด๋‹น ๋‚ด์šฉ ๊ด€๋ จํ•ด์„œ ์„ค๋ช…ํ•˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค. ์ฝ”๋ฉ˜ํŠธ์—๋‹ค๊ฐ€ ์ด๋ฉ”์ผ ์ฃผ์†Œ๋ฅผ ์“ฐ๋Š” ๊ฑฐ์˜€์—ˆ๋‹ค. 

 

GitLab ๋ฌธ์„œ ๋‚ด์šฉ

 

 

์–ด๋–ค ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์จ์•ผํ•  ์ง€๋Š” ๊ฐœ์ธ์˜ ์„ ํƒ์— ๋งก๊ธฐ๊ฒŒ ํ•ด๋†“์•˜๋Š”๋ฐ... ์™œ ๊ตฌ์ง€ ์•Œ๊ณ ๋ฆฌ์ฆ˜๋“ค์— ๋Œ€ํ•ด์„œ GitLab ๊ณต์‹ ๋ฌธ์„œ์— ์จ๋†จ๋‚˜ ํ–ˆ๋”๋‹ˆ ์ด๋Ÿฐ ์ด์œ  ๋•Œ๋ฌธ์ธ๊ฐ€ ๋ณด๋‹ค. 

 

"์ฝ”๋ฉ˜ํŠธ๋ฅผ ์™œ ์จ์•ผ ํ•˜๋Š”๊ฐ€"์— ๋Œ€ํ•ด ๊ถ๊ธˆํ•ด์ ธ์„œ ์ฐพ์•„๋ดค๋‹ค.

์ด๋ฆฌ์ €๋ฆฌ ๋’ค์ง€๋‹ค๊ฐ€ ์š” ํŽ˜์ด์ง€๊นŒ์ง€ ๊ฐ€์„œ comment์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒŒ ๋˜์—ˆ๋‹ค.

 

http://man.openbsd.org/sshd.8

 

sshd(8) - OpenBSD manual pages

sshd — OpenSSH daemon sshd [-46DdeGiqTtV] [-C connection_spec] [-c host_certificate_file] [-E log_file] [-f config_file] [-g login_grace_time] [-h host_key_file] [-o option] [-p port] [-u len] sshd (OpenSSH Daemon) is the daemon program for ssh(

man.openbsd.org

 

์ด ํŽ˜์ด์ง€์— ๋”ฐ๋ฅด๋ฉด ์ฝ”๋ฉ˜ํŠธ... ์•ˆ ์“ฐ์ธ๋‹ค๊ณ  ํ•œ๋‹ค.

 

์ฝ”๋ฉ˜ํŠธ ์•ˆ ์“ด๋‹ค1

 

์ฝ”๋ฉ˜ํŠธ ์•ˆ ์“ด๋‹ค2. ์ฝ”๋ฉ˜ํŠธ๋Š” ์ฒ ์ €ํžˆ ๋ฌด์‹œ๋˜๋Š” ์กด์žฌ์ธ๊ฐ€ ๋ณด๋‹ค.

 

๋‹ค์‹œ ๋Œ์•„์™€์„œ.

SSH ํ‚ค ์ƒ์„ฑ ๊ณผ์ •

 

์ฝ”๋ฉ˜ํŠธ๋ฅผ ๋‹ฌ์•„์„œ SSH ํ‚ค๋ฅผ ์ƒ์„ฑํ–ˆ๊ณ , ์ƒ์„ฑ ์œ„์น˜๋ฅผ ๋ณด์—ฌ์ฃผ๋ฉด์„œ ํ‚ค๋ฅผ ์ €์žฅํ•  ๊ฑฐ๋ฉด ์—”ํ„ฐ ํ‚ค๋ฅผ ์น˜๋ผ๊ณ  ํ•œ๋‹ค.

์—”ํ„ฐํ‚ค๋ฅผ ์น˜๋ฉด passphrase ๊ฐ’์„ ์ž…๋ ฅํ•˜๋ผ๊ณ  ํ•œ๋‹ค. passphrase ๊ฐ’์„ ์น˜๊ณ  ์—”ํ„ฐ๋ฅผ ๋ˆ„๋ฅด๋‹ˆ

 

SSH ํ‚ค ์ƒ์„ฑ ์™„๋ฃŒ

passphrase ๊ฐ’์„ ํ•œ ๋ฒˆ ๋” ํ™•์ธํ•˜๊ณ  ๋งŒ๋“ค์–ด์ค€๋‹ค.

 

passphrase๋Š” ๋ฌด์—‡์ธ๊ฐ€ ํ•˜๋Š” ๋‚ด์šฉ์€ https://www.ssh.com/academy/ssh/passphrase ์—์„œ ํ™•์ธํ•˜๋ผ๊ณ  GitLab ๋ฌธ์„œ์— ๋‚˜์˜จ๋‹ค. password๋Š” ๋กœ๊ทธ์ธ, ์ธ์ฆ์šฉ ์•”ํ˜ธ๋ผ๋ฉด, pawwphrase๋Š” ์•”ํ˜ธํ‚ค ๋ณดํ˜ธ์šฉ ์•”ํ˜ธ์ธ๊ฐ€ ๋ณด๋‹ค.

 

๋””๋ ‰ํ† ๋ฆฌ์™€ ํŒŒ์ผ์ด ์ƒ๊ฒผ๋‹ค

 

์ •์ƒ์ ์œผ๋กœ ํด๋”์™€ SSH ํ‚ค ํŒŒ์ผ์ด ์ƒ๊ธด ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค.

 

3) GitLab์— SSH ํ‚ค ๋“ฑ๋กํ•˜๊ธฐ

 

".pub"๋กœ ํ™•์žฅ์ž๊ฐ€ ๋ช…์‹œ๋œ SSH ํ‚ค๊ฐ€ public ํ‚ค์ธ๋“ฏ ํ•˜๋‹ค. ์š” ํŒŒ์ผ์„ ์—ด์–ด ๋ณต์‚ฌํ•œ ๋‚ด์šฉ์„ Key ์ž…๋ ฅ์นธ์— ๋„ฃ์—ˆ๋‹ค. Title์€ ํ‚ค๋ฅผ ์ž…๋ ฅํ•˜์ž ํ‚ค ๋งจ ๋’ค์˜ ์ฝ”๋ฉ˜ํŠธ๊ฐ€ ์ €์ ˆ๋กœ ๋“ค์–ด๊ฐ”๋‹ค.

 

์™„๋ฃŒ!