Post

Zzikzzik CICD_Permission Denied

๐Ÿ”ด Permission Denied(public key, password)

Image

โœ… Reference

โœ… CICD reference

โœ… Key setting reference

https://m.blog.naver.com/awspro/221964190924

โ˜‘๏ธ open .pem ํ‚ค ํ™•์ธํ•˜๊ธฐ

  • ํ‚ค ์žˆ๋Š” ์žฅ์†Œ๋กœ ๊ฐ€์„œ cat zzikzzikKey.pem
  • ์ด๊ฒŒ ๋ฐ”๋กœ SSH_PRIVATE_KEY

โ˜‘๏ธ PRIVATE ํ‚ค ๋ชจ์–‘, ์ €์žฅ ์œ„์น˜

SSH_PRIVATE_KEY ๋Š”

1
2
3
-----BEGIN RSA PRIVATE KEY-----
โ€ฆ
-----END RSA PRIVATE KEY-----

์ด๋ ‡๊ฒŒ ์ƒ๊น€

  • repository secret in Project > Settings > Secrets and Variables > Actions ์— ์ €์žฅ
  • Add a new secret with the name SSH_PRIVATE_KEY and paste the contents of your .pem file or private SSH key

โ˜‘๏ธ PUBLIC ํ‚ค ๋ชจ์–‘, ์ €์žฅ ์œ„์น˜

  • ๋ฐ˜๋ฉด public key๋Š”
  • ssh-rsa AAAAB3โ€ฆ user@example.com
  • ์ด๋ ‡๊ฒŒ ์ƒ๊น€

  • GitHub user profile > SSH and GPG Keys์— ์ €์žฅํ•ด์•ผ ํ•œ๋‹ค.

public key๋ฅผ authorized_keys์— ์ €์žฅ

1
2
cat ~/.ssh/zzikzzik_key.pub >> ~/.ssh/authorized_keys
~/.ssh/authorized_keys

Image

1
ls -l ~/.ssh/authorized_keys

authorized_keys๋ณผ ๊ถŒํ•œ์ด ec2-user์—๊ฒŒ ์žˆ๋‹ค๋Š” ์˜๋ฏธ

Image

  • catํ•ด์„œ
  • ์•ˆ์— public key ์ €์žฅ๋˜์–ด ์žˆ๋Š”๊ฒƒ ํ™•์ธ

Image

โ˜‘๏ธ ๊ถŒํ•œ ๋ถ€์—ฌ

1
2
3
4
chmod 600 ~/.ssh/zzikzzik_key
chmod 644 ~/.ssh/zzikzzik_key.pub
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

โ˜‘๏ธ

โ˜‘๏ธ

This post is licensed under CC BY 4.0 by the author.