๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
IT-Engineering/TroubleShooting

Mac Permission denied pulickey ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•(์žฌ๋ถ€ํŒ…)

by ๐Ÿงž‍โ™‚๏ธ 2022. 9. 7.
๋ฐ˜์‘ํ˜•

"mac์—์„œ ์žฌ๋ถ€ํŒ…ํ•  ๋•Œ๋งˆ๋‹ค git push๊ฐ€ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ"

 

mac์œผ๋กœ ๊ฐˆ์•„ํƒ„ ํ›„ ์ž˜ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋˜ github๊ณ„์ •์— push๋ฅผ ํ•˜๋ ค๊ณ  ํ•˜์ž ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜ํƒ€๋‚ฌ๋‹ค.

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

 

1์ฐจ์ ์œผ๋กœ๋Š” ์ด์ „์— ํฌ์ŠคํŒ…ํ•œ ์ ์ด ์žˆ๋Š”, ์•„๋ž˜์˜ ๊ธ€๋กœ ํ•ด๊ฒฐ์ด ๋๋‹ค.

https://gentlesark.tistory.com/86

 

Git Push๋ฅผ ๊ท€์ฐฎ๊ฒŒ ๋งŒ๋“œ๋Š” ์—๋Ÿฌ ํ•ด๊ฒฐ: Enter passphrase for key '~/.ssh/id_rsa' ๋ฌธ์ œ์™€ Could not open a connection to

์–ธ์  ๊ฐ€๋ถ€ํ„ฐ https๋กœ git repository๋กœ๋ถ€ํ„ฐ ์†Œ์Šค๋ฅผ ๋ฐ›์„ ๋•Œ ์ž๊พธ ๊ณ„์ • ํ™•์ธ์ด ๋œจ๋Š”๊ฒŒ ๊ท€์ฐฎ์•˜๋‹ค. ๊ทธ๋ž˜์„œ ssh key๋“ฑ๋ก์„ ํ•˜๊ณ  ํ•œ๋ฒˆ ๊ท€์ฐฎ์Œ์„ ๊ฐ์ˆ˜ํ•˜๊ณ  ๊ณ„์† ํŽธํ•˜๊ฒŒ ํ•˜๋ ค๊ณ  ssh ์„ค์ •์„ ๊ฐํ–‰ํ–ˆ๋‹ค. git push์‹œ ์ž

gentlesark.tistory.com

 

 
ํ˜น์‹œ๋ผ๋„ ssh-key๊ฐ€ ์—†๋‹ค๋ฉด, ์•„๋ž˜์˜ ๊ธ€ ์ฐธ์กฐ
 
 

mac์—์„œ ssh-key ์ƒ์„ฑํ•˜๊ธฐ(ssh-keygen)

1. ํ„ฐ๋ฏธ๋„์„ ์‹คํ–‰ํ•œ๋‹ค. (์œ„์™€ ๊ฐ™์€ ์•„์ด์ฝ˜) 2. ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. (์ด๋ฉ”์ผ ์ฃผ์†Œ๋Š” ๋ณธ์ธ์— ๋งž๊ฒŒ ๋ณ€๊ฒฝ) ssh-keygen -C "abcd@naver.com" 3. ์•„๋ž˜์˜ ๋ฉ”์‹œ์ง€๊ฐ€ ๋‚˜์˜ค๋ฉด Enter๋ฅผ ์ž…๋ ฅํ•œ๋‹ค. (๊ธฐ๋ณธ ๊ฒฝ๋กœ์— ์ €์žฅ

gentlesark.tistory.com

 
 
 
๋ฌธ์ œ๋Š” ์žฌ๋ถ€ํŒ…(mac ์žฌ์‹œ๋™)ํ•˜๋ฉด ๋ฐ˜๋ณต๋œ๋‹ค๋Š” ๊ฒƒ์ด์—ˆ๋‹ค...!
 
 
OS๋ฅผ ์žฌ์‹œ์ž‘ ํ›„์— ssh-add -l ์„ ์ž…๋ ฅํ•ด๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ๋‹ค. ์•„๋ž˜์™€ ๊ฐ™์ด ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.
 
The agent has no identities.
 
 
์œ„์—์„œ ํ–ˆ๋“ฏ์ด ssh-add๋ฅผ ํ†ตํ•ด ๋‹ค์‹œ ๋“ฑ๋กํ•ด์ฃผ๋ฉด ์ž˜ ์ž‘๋™ํ•œ๋‹ค. ํ•˜์ง€๋งŒ ์žฌ๋ถ€ํŒ…ํ•  ๋•Œ๋งˆ๋‹ค ์ด๋ ‡๊ฒŒ ํ•˜๊ธฐ๋ž€ ๋„ˆ๋ฌด ๋ฒˆ๊ฑฐ๋กญ๋‹ค. ๊ทธ๋ž˜์„œ ํ•ด๊ฒฐํ•  ๋ฐฉ๋ฒ•์„ ๋” ์ฐพ์•„๋ณด์•˜๋‹ค. ๊ฒฐ๊ตญ ํ•ด๊ฒฐํ–ˆ๋‹ค.(๋ถ€ํŒ…์‹œ ssh-add -l ๋ฅผ ์ž…๋ ฅํ–ˆ์„ ๋•Œ ์•„๋ฌด๊ฒƒ๋„ ๋œจ์ง€ ์•Š์•„๋„ ์ƒ๊ด€์—†๋‹ค.) ์ฐธ๊ณ ์ž๋ฃŒ๋Š” ๋งจ ๋’ค์— ๋ถ™์—ฌ๋„ฃ๊ฒ ๋‹ค.
 
 

 ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

 

macOS Sierra ์ดํ›„๋กœ๋Š” ํ‚ค์ฒด์ธ์„ ์‚ฌ์šฉํ•˜๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ssh-key๊ฐ€ ์ž„์‹œ์ ์œผ๋กœ๋งŒ ์ €์žฅ๋˜๋Š” ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

vi ~/.ssh/config
 
๋ฅผ ํ†ตํ•ด vi ์—๋””ํ„ฐ ์ง„์ž… ํ›„ ์•„๋ž˜์˜ ๋‚ด์šฉ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•œ๋‹ค.
 
Host *
  IdentityFile ~/.ssh/id_rsa
  UseKeyChain yes
  AddKeysToAgent yes

 

์ถ”๊ฐ€์ ์œผ๋กœ Passphrase๋Š” ์ž…๋ ฅ์ด ๊ท€์ฐฎ๊ธฐ๋„ ํ•ด์„œ

ssh-keygen -p

๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด์„œ ์—†์• ์ฃผ์—ˆ๋‹ค.


์ฐธ๊ณ ์ž๋ฃŒ

 

https://unix.stackexchange.com/questions/140075/ssh-add-is-not-persistent-between-reboots

 

ssh-add is not persistent between reboots

I added a ssh key to the agent by: $ ssh-add ~/.ssh/id_rsa_mac Identity added: /Users/alex/.ssh/id_rsa_mac (/Users/alex/.ssh/id_rsa_mac) After a reboot the agent doesn't have this key added anymo...

unix.stackexchange.com

https://gentlesark.tistory.com/65

 

git push์‹œ ์ž๋™ ๋กœ๊ทธ์ธ ์„ค์ • - SSH ์„ค์ •์œผ๋กœ username, password ๊ทธ๋งŒ ์ž…๋ ฅํ•˜์ž

github respository์— git push -u origin master ๋ฅผ ํ–ˆ์„ ๋•Œ ์•„๋ž˜์™€ ๊ฐ™์ด ์ž๊พธ ๋กœ๊ทธ์ธ์„ ์š”์ฒญํ•˜๋Š” ๊ฒฝ์šฐ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• ์ •๋ฆฌ. repository์ฃผ์†Œ๋ฅผ https ๋กœ ๋ฐ›์•„์„œ ์ฒ˜๋ฆฌํ•˜๋˜ ๊ฒฝ์šฐ์— ํ”„๋กœํ† ์ฝœ์„ ssh ๋กœ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค..

gentlesark.tistory.com

https://apple.stackexchange.com/questions/254468/macos-sierra-doesn-t-seem-to-remember-ssh-keys-between-reboots/254714#254714

 

macOS Sierra doesn’t seem to remember SSH keys between reboots

I have to run this command since upgrading to macOS: ssh-add -K Corrects the problem after the reboot but I have to run this command every time I log on to my computer. If I do not run the command

apple.stackexchange.com

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€