๋ฐ˜์‘ํ˜•

1Password SSH ํ‚ค ์ƒ์„ฑ ํ™”๋ฉด

1Password 8 ๋ฒ„์ „๋ถ€ํ„ฐ SSH & Git ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ํ˜„์žฌ Ed25519์™€ RSA ๋‘๊ฐ€์ง€ ํƒ€์ž…์„ ์ง€์›ํ•˜๋ฉฐ, ๊ธฐ์กด SSH ํ‚ค๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ์ €์žฅํ•  ์ˆ˜๋„ ์žˆ๋‹ค. ์ฐธ๊ณ ๋กœ *.pem ํŒŒ์ผ์„ 1Password์— ๋ถˆ๋Ÿฌ์™€์„œ ์ €์žฅํ•œ ํ›„, ๊ฐœ์ธํ‚ค๋ฅผ ๋‹ค์‹œ ๋‹ค์šด๋กœ๋“œํ•ด์„œ ์‚ฌ์šฉํ•  ๋• pem ํ™•์žฅ์ž๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ•œ๋‹ค.

 

1Password์˜ SSH & Git ๊ด€๋ฆฌ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•˜๋ฉด SSH ๊ฐœ์ธํ‚ค๋ฅผ ๋กœ์ปฌ์— ์ €์žฅํ•˜์ง€ ์•Š๊ณ ๋„ SSH ์ธ์ฆ์„ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. ~/.ssh/config ํŒŒ์ผ์— ์ผ์ผ์ด SSH ํ‚ค ๊ฒฝ๋กœ๋ฅผ ๋ช…์‹œํ•ด์•ผ ํ•˜๋Š” ๋ฒˆ๊ฑฐ๋กœ์›€๋„ ๋œ ์ˆ˜ ์žˆ๋‹ค.

 

1Password์—์„œ ์ƒ์„ฑํ•œ SSH ํ‚ค๋Š” ๊ณต๊ฐœํ‚ค์™€ ํ•‘๊ฑฐ ํ”„๋ฆฐํŠธ(Finger Print)๋ฅผ ํ•จ๊ป˜ ์ƒ์„ฑํ•˜๊ธฐ ๋•Œ๋ฌธ์— GitHub ๊ฐ™์€ ์„œ๋น„์Šค์—์„œ ๊ณต๊ฐœํ‚ค ์ž๋™์™„์„ฑ ๊ธฐ๋Šฅ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ณ„๊ฑฐ ์•„๋‹Œ ๊ฒƒ ๊ฐ™์ง€๋งŒ ์€๊ทผํžˆ ์œ ์šฉํ•˜๋‹ค.

 

์„ค์ • ๋ฐฉ๋ฒ•


โถ 1Password SSH ์—์ด์ „ํŠธ ํ™œ์„ฑํ™”

 

 

  • ์„ค์ • → ๊ฐœ๋ฐœ์ž → SSH ์—์ด์ „ํŠธ ์‚ฌ์šฉ : ์ฒดํฌ
  • ์„ค์ • → ๊ฐœ๋ฐœ์ž → ์—ฐ๊ฒฐ์„ ์Šน์ธํ•  ๋•Œ ํ‚ค ์ด๋ฆ„ ํ‘œ์‹œ : ์ฒดํฌ

 

โท ~/.password/agent.sock ๊ฒฝ๋กœ์— ๋Œ€ํ•œ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ ์ถ”๊ฐ€

mkdir -p ~/.1password && ln -s ~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock ~/.1password/agent.sock

 

  • mkdir -p ์˜ต์…˜ : ์žฌ๊ท€์ ์œผ๋กœ ํด๋” ์ƒ์„ฑ(์ค‘๊ฐ„ ๊ฒฝ๋กœ์— ๋Œ€ํ•œ ํด๋”๊ฐ€ ์—†๋‹ค๋ฉด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋จ)
  • ln : ๋งํฌ ์ƒ์„ฑ ex) ln ์†Œ์ŠคํŒŒ์ผ ํƒ€๊ฒŸ๊ฒฝ๋กœ
  • ln -s ์˜ต์…˜ : ์‹ฌ๋ณผ๋ฆญ ๋งํฌ(symlink) ์ƒ์„ฑ

 

โธ ~/.ssh/configํŒŒ์ผ์— 1Password SSH ์—์ด์ „ํŠธ ๊ฒฝ๋กœ ์ถ”๊ฐ€. Host * ๋ถ€๋ถ„์— ์ถ”๊ฐ€ํ–ˆ์œผ๋ฏ€๋กœ ๋ชจ๋“  ํ˜ธ์ŠคํŠธ์— ๋Œ€ํ•ด 1Password ์—์ด์ „ํŠธ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. 1Password์—์„œ ๊ด€๋ฆฌํ•˜๋Š” SSH ํ‚ค๋Š” IdentityFile ํ•ญ๋ชฉ์— ์ผ์ผ์ด ๊ฒฝ๋กœ๋ฅผ ๋ช…์‹œํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

# ~/.ssh/config
Host *
  IdentityAgent ~/.password/agent.sock

 

ํŠน์ • ํ˜ธ์ŠคํŠธ์—๋งŒ 1Password ์—์ด์ „ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ํ•  ์ˆ˜ ์žˆ๋‹ค. github-home ํ˜ธ์ŠคํŠธ๋Š” 1Password ์—์ด์ „ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ec2-server ํ˜ธ์ŠคํŠธ๋Š” ๋กœ์ปฌ์— ์ €์žฅ๋œ SSH ํ‚ค(pem ํŒŒ์ผ)๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์‹œ โ–ผ

# A host that's using the 1Password agent
Host github-home
  HostName github.com
  User pi
  IdentityAgent ~/.1password/agent.sock

# A host that's using a local private key file that's not saved in 1Password
Host ec2-server
  HostName 54.123.45.67
  User ec2-user
  IdentityFile ~/.ssh/ssh-key-not-on-1password.pem

 

์‚ฌ์šฉ


ํ„ฐ๋ฏธ๋„์ด๋‚˜ SSH ํด๋ผ์ด์–ธํŠธ์—์„œ git pull ... ๊ฐ™์€ SSH ํ‚ค๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋ฉด SSH ํ‚ค ์‚ฌ์šฉ ์Šน์ธ ํŒ์—…์ด ๋œฌ๋‹ค. ์š”์ฒญ์„ ์Šน์ธํ•˜๋ฉด 1Password๊ฐ€ ์ž ๊ธธ๋•Œ๊นŒ์ง€ ๋™์ผํ•œ SSH ํ‚ค๋Š” ๋ณ„๋„ ์Šน์ธ์—†์ด ๊ณ„์† ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค(Touch ID / Windows Hello ๊ฐ™์€ ์ƒ์ฒด ์ธ์‹์œผ๋กœ ์Šน์ธ ๊ฐ€๋Šฅ).

 

EC2 ์ธ์Šคํ„ด์Šค ์ ‘์†์‹œ ๋‚˜์˜ค๋Š” ์•ก์„ธ์Šค ํ—ˆ์šฉ ํŒ์—…

1Password์— SSH ํ‚ค๋ฅผ ์ €์žฅํ•ด๋‘๋ฉด ์›น์‚ฌ์ดํŠธ์— ๊ณต๊ฐœํ‚ค๋ฅผ ๋“ฑ๋กํ•  ๋•Œ ์ž๋™ ์™„์„ฑ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ์ผ์ผ์ด ๊ณต๊ฐœํ‚ค๋ฅผ ๋ณต์‚ฌ / ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค. ๊ณต๊ฐœํ‚ค ์ž๋™ ์™„์„ฑ ๊ธฐ๋Šฅ์€ GitHub, GitLab ๋“ฑ์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

 

๐Ÿ’ก 1Password์—์„œ SSH ํ‚ค๋ฅผ ์ƒ์„ฑ(์ €์žฅ)ํ•˜๋ฉด ๊ณต๊ฐœํ‚ค์™€ ํ•‘๊ฑฐ ํ”„๋ฆฐํŠธ(Finger Print)๊ฐ€ ํ•จ๊ป˜ ์ƒ์„ฑ๋˜๋ฉฐ, ~/.ssh/config ํŒŒ์ผ์— SSH ํ‚ค ๊ฒฝ๋กœ๋ฅผ ๋ช…์‹œํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค.

 

GitHub ๊ณต๊ฐœํ‚ค ๋“ฑ๋ก ํŽ˜์ด์ง€(SSH and GPG keys)์˜ ์ž๋™ ์™„์„ฑ ํŒ์—…์ฐฝ

๐Ÿ” ์ž๋™ ์™„์„ฑ ์ง€์› ์‚ฌ์ดํŠธ ๋ชฉ๋ก - ๊ณต์‹ ๋ฌธ์„œ

  • Bitbucket
  • DigitalOcean
  • GitHub
  • GitLab
  • Google Compute Engine
  • Linode
  • Microsoft Azure
  • Ngrok
  • Vultr

 

SSH ํด๋ผ์ด์–ธํŠธ ํ˜ธํ™˜์„ฑ


macOS, Linux์˜ SSH / Git ํด๋ผ์ด์–ธํŠธ๋Š” ~/.ssh/config ํŒŒ์ผ์˜ IdentityAgent ์„ค์ •์„ ํ™•์ธํ•œ ํ›„ ์—์ด์ „ํŠธ ์†Œ์ผ“ ๊ฒฝ๋กœ(agent socket path)๋ฅผ ์‚ฌ์šฉํ•ด์„œ SSH ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•œ๋‹ค. ํ•˜์ง€๋งŒ ๋ชจ๋“  SSH ํด๋ผ์ด์–ธํŠธ๊ฐ€ IdentityAgent ๊ตฌ์„ฑ์„ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค.

 

๐Ÿ’ก SSH Client ํ˜ธํ™˜์„ฑ ๋ชฉ๋ก ์ผ๋ถ€ ๋‚ด์šฉ ๋ฐœ์ทŒ. ๋” ์ž์„ธํ•œ ๋ชฉ๋ก์€ ๊ณต์‹ ๋ฌธ์„œ ์ฐธ๊ณ 

Name SSH Capability Compatible with 1Password
Fork Git โœ…
Sourcetree Git โœ…
GitHub Desktop Git โœ…
git CLI Git โœ…
OpenSSH SSH, SFTP โœ…
JetBrains IDEs Git โœ…
Visual Studio Code Git โœ…
Xcode Git โŒ

 

macOS์™€ Linux์—์„  SSH_AUTH_SOCK ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ์—์ด์ „ํŠธ ์†Œ์ผ“ ๊ฒฝ๋กœ๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ์ผ๋ฐ˜์ ์œผ๋กœ IdentityAgent ๋ณด๋‹ค SSH_AUTH_SOCK ์„ ์ง€์›ํ•˜๋Š” SSH ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋” ๋งŽ๋‹ค. ์‚ฌ์šฉํ•˜๋Š” ํด๋ผ์ด์–ธํŠธ๊ฐ€ IdentityAgent๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด SSH_AUTH_SOCK ์„ค์ •์„ ํ†ตํ•ด ํ˜ธํ™˜์„ฑ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค. โ–ผ

# SSH_AUTH_SOCK ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•˜๋Š” ์ปค๋งจ๋“œ(ํ˜„์žฌ ํ„ฐ๋ฏธ๋„์—์„œ๋งŒ ์œ ํšจ) 
export SSH_AUTH_SOCK=~/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock

 

๋ชจ๋“  ํด๋ผ์ด์–ธํŠธ์— SSH_AUTH_SOCK ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์ž๋™์œผ๋กœ ๊ตฌ์„ฑํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์•„๋ž˜ ์ปค๋งจ๋“œ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.

# SSH_AUTH_SOCK์„ ์ „์—ญ์œผ๋กœ ๊ตฌ์„ฑํ•˜๋Š” ์ปค๋งจ๋“œ 
cat << EOF > ~/Library/LaunchAgents/com.1password.SSH_AUTH_SOCK.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>com.1password.SSH_AUTH_SOCK</string>
  <key>ProgramArguments</key>
  <array>
    <string>/bin/sh</string>
    <string>-c</string>
    <string>/bin/ln -sf $HOME/Library/Group\ Containers/2BUA8C4S2C.com.1password/t/agent.sock \$SSH_AUTH_SOCK</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
</dict>
</plist>
EOF
launchctl load -w ~/Library/LaunchAgents/com.1password.SSH_AUTH_SOCK.plist
๋”๋ณด๊ธฐ

โถ 1Password 8 SSH ์—์ด์ „ํŠธ ์–ธ๋กœ๋“œ

launchctl unload ~/Library/LaunchAgents/com.1password.SSH_AUTH_SOCK.plist

 

โท plist ์‚ญ์ œ (์—์ด์ „ํŠธ๋ฅผ ์–ธ๋กœ๋“œํ•ด๋„ ์žฌ๋ถ€ํŒ…ํ•˜๋ฉด ๋‹ค์‹œ ๋กœ๋“œ๋˜๋ฏ€๋กœ plist๋ฅผ ์‚ญ์ œํ•ด์•ผ๋จ)

rm ~/Library/LaunchAgents/com.1password.SSH_AUTH_SOCK.plist

 

โธ ์žฌ๋ถ€ํŒ…

 

๋ฒˆ์™ธ — HERODOC


EOF๋Š” End Of File์˜ ์•ฝ์ž๋กœ ํŒŒ์ผ์˜ ๋์„ ์•Œ๋ฆด ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. cat << EOF ๋Š” HERODOC ๊ตฌ๋ฌธ ํ˜•์‹์œผ๋กœ ์—ฌ๋Ÿฌ ์ค„์˜ ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•  ๋•Œ(EOF ์‹๋ณ„์ž ์ด์ „๊นŒ์ง€) ์‚ฌ์šฉํ•œ๋‹ค.

 

cat << EOF > [ํŒŒ์ผ๋ช…] ํ˜•์‹์œผ๋กœ ์ž…๋ ฅํ•˜๋ฉด ์ž‘์„ฑํ•œ ๋ฉ€ํ‹ฐ๋ผ์ธ ํ…์ŠคํŠธ๋ฅผ ๋ช…์‹œํ•œ ํŒŒ์ผ์— ์ €์žฅํ•œ๋‹ค. EOF ์™ธ์— STOP ๊ฐ™์€ ๋‹ค๋ฅธ ์‹๋ณ„์ž๋ฅผ ์‚ฌ์šฉํ•ด๋„ ๋˜๋ฉฐ, ์ฒ˜์Œ์— ์‚ฌ์šฉํ•œ ์‹๋ณ„์ž์™€ ๋ ์‹๋ณ„์ž๊ฐ€ ์ผ์น˜ํ•ด์•ผ ๋œ๋‹ค.

cat << EOF > helloworld.txt
> Hello
> World
> EOF

cat helloworld.txt
# Hello
# World

 

๋ ˆํฌ์ง€ํ† ๋ฆฌ๋งˆ๋‹ค ๋‹ค๋ฅธ SSH ํ‚ค ์‚ฌ์šฉํ•˜๊ธฐ


1Password์— ์ €์žฅํ•œ SSH ํ‚ค๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ๋ผ๋ฉด ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋งˆ๋‹ค ๊ฐ๊ฐ ๋‹ค๋ฅธ SSH key๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

โถ 1Password์— ์ €์žฅํ•ด๋‘” SSH ๊ณต๊ฐœํ‚ค(๊ฐœ์ธ ๋ฐ ํšŒ์‚ฌ์šฉ) ๋‹ค์šด๋กœ๋“œ

 
โท ๋‹ค์šด๋ฐ›์€ ๊ณต๊ฐœํ‚ค๋“ค์„ ~/.ssh ๊ฒฝ๋กœ์— ์ €์žฅ. ๊ตฌ๋ถ„ํ•˜๊ธฐ ์‰ฝ๊ฒŒ personal-github.pub ๋“ฑ ์ด๋ฆ„์œผ๋กœ ์ง€์ •
 

โธ ~/.ssh/config ํŒŒ์ผ ์ˆ˜์ •

# Personal GitHub (๋„์–ด์“ฐ๊ธฐ๋กœ ๊ตฌ๋ถ„ํ•ด์„œ Host ์ด๋ฆ„ 2๊ฐœ ์ž…๋ ฅํ•จ)
Host github.com personal-github
  HostName github.com
  User git
  IdentityFile ~/.ssh/personal-github.pub
  IdentitiesOnly yes

# Work GitHub
Host work-github
  HostName github.com
  User git
  IdentityFile ~/.ssh/work-github.pub
  IdentitiesOnly yes

  

  • Host ์ด๋ฆ„์€ ์ž„์˜ ์ง€์ • ํ•  ์ˆ˜ ์žˆ๊ณ , ๋„์–ด์“ฐ๊ธฐ๋กœ ๊ตฌ๋ถ„ํ•ด์„œ ์—ฌ๋Ÿฌ๊ฐœ ์ž…๋ ฅ ๊ฐ€๋Šฅ ex) gh1, gh2
  • IdentitiesOnly ์˜ต์…˜์„ yes๋กœ ์„ค์ •ํ•˜๋ฉด ์ธ์ฆ์‹œ IdentityFile์— ๋ช…์‹œํ•œ ํ‚ค ํŒŒ์ผ๋งŒ ์‚ฌ์šฉ
  • User(์œ ์ €์ด๋ฆ„)์— git์„ ๋ช…์‹œํ–ˆ์œผ๋ฏ€๋กœ host ์ฃผ์†Œ ์•ž์— git@์„ ๋ถ™์ธ ๊ฒƒ๊ณผ ๋™์ผ
    ex) ssh -T github.com ssh -T git@github.com ๋‘˜๋‹ค ๋™์ผ

 

โน ๋ ˆํฌ์ง€ํ† ๋ฆฌ remote ์ฃผ์†Œ์˜ host๋ฅผ github.com ๋Œ€์‹  .ssh/config ํŒŒ์ผ์— ์ง€์ •ํ•œ ์ด๋ฆ„์œผ๋กœ ๋ณ€๊ฒฝ

git remote set-url origin host:workplace/repo.git

 

# github.com(๊ธฐ๋ณธ๊ฐ’) ํ˜ธ์ŠคํŠธ ๋ณ€๊ฒฝ ์˜ˆ์‹œ
# personal-github ํ˜ธ์ŠคํŠธ (๊ฐœ์ธ ๋ ˆํฌ์ง€ํ† ๋ฆฌ)
git remote set-url origin personal-github:romantech/practice.git

# work-github ํ˜ธ์ŠคํŠธ (ํšŒ์‚ฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ)
git remote set-url origin work-github:google/gmail.git

 

๋ ˆํผ๋Ÿฐ์Šค


 


๊ธ€ ์ˆ˜์ •์‚ฌํ•ญ์€ ๋…ธ์…˜ ํŽ˜์ด์ง€์— ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค. ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด ์ฃผ์„ธ์š”
๋ฐ˜์‘ํ˜•