๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
BackEnd๐ŸŒฑ/Etc

Sourcetree "permission denied (publickey)" error ํ•ด๊ฒฐ

by dkswnkk 2022. 7. 6.

๋ฌธ์ œ

Sourcetree๋ฅผ ์ด์šฉํ•ด push๋ฅผ ํ•˜๋Š” ๊ณผ์ •์—์„œ "permission denied (publickey)" ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•ด์„œ ์ง„ํ–‰์ด ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ๋ฌธ์ œ๋Š” SSH ์ธ์ฆ์— ๋ฌธ์ œ๊ฐ€ ์žˆ์„ ๊ฒฝ์šฐ ๋ฐœ์ƒํ•˜๋Š”๋ฐ, ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

 

ํ•ด๊ฒฐ

1. ssh-keygen "ํŒŒ์ผ ์ด๋ฆ„"์„ ์ž…๋ ฅํ•˜์—ฌ ์ƒˆ๋กœ์šด ssh๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

ssh-keygen ์˜ˆ์‹œ

์‚ฌ์šฉํ•  ๋น„๋ฐ€๋ฒˆํ˜ธ๊นŒ์ง€ ์ž…๋ ฅํ•˜๊ฒŒ ๋˜๋ฉด ์ง€์ •ํ•œ์ด๋ฆ„.pub ํ˜•์‹์œผ๋กœ ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

 

2. cat ํŒŒ์ผ์ด๋ฆ„.pub์„ ํ†ตํ•ด์„œ ์ƒ์„ฑ๋œ ํ‚ค ๊ฐ’์„ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

ํ‚ค ๊ฐ’์„ ๋ณต์‚ฌ

ํŒŒ๋ž€์ƒ‰์œผ๋กœ ์น ํ•ด์ง„ ๋ฌธ์ž๋งŒ ๋ณต์‚ฌํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

3. GitHub -> Settings -> SSH and GPG keys -> New SSH key์—์„œ 2๋ฒˆ์—์„œ ๋ณต์‚ฌํ•œ ํ‚ค๋ฅผ ์ž…๋ ฅํ•ด ์ค๋‹ˆ๋‹ค.

 

4.ssh-add -l ๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

๋‹ค์Œ๊ณผ ๊ฐ™์ด The agent has no identities.๋ผ๊ณ  ์ถœ๋ ฅ๋œ๋‹ค๋ฉด ์ •์ƒ์ ์œผ๋กœ ๋œ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

5. ssh-add -K ~/.ssh/ํŒŒ์ผ์ด๋ฆ„ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด local์— ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.

 

์ด์ œ ๋ชจ๋“  ์ž‘์—…์ด ๋๋‚ฌ๊ณ , Sourcetree๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ž‘๋™ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

๋Œ“๊ธ€