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

OS/๐Ÿง Linux

๐Ÿง Ubuntu * ๊ณต๊ฐœํ‚ค ์ƒ์„ฑํ•˜๊ธฐ

1. ๊ณต๊ฐœํ‚ค ๋“ฑ๋ก ์ „ ํ™•์ธ!

์ผ๋‹จ ํ˜น์‹œ๋ผ๋„ ๋‚ด๊ฐ€ ๊ณต๊ฐœํ‚ค๋ฅผ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ ๊นŒ๋จน๊ณ  ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋‹ˆ ๊ณต๊ฐœํ‚ค๊ฐ€ ์žˆ๋Š”์ง€๋ถ€ํ„ฐ ํ™•์ธํ•˜์ž.

 

$ cd ~/.ssh
$ ls

๋ชฉ๋ก์— id_rsa.pub ์ด๋ผ๋Š” ํŒŒ์ผ์ด ์žˆ์œผ๋ฉด ์ด๋ฏธ ๋‚˜๋Š” ๊ณต๊ฐœํ‚ค๋ฅผ ์ƒ์„ฑํ•œ ๊ฒƒ์ด๋‹ค.

 

2. ์—†๋‹ค๋ฉด ์ƒ์„ฑํ•˜์ž

$ ssh-keygen -t rsa

์œ„์˜ ๋ช…๋ น์–ด๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐœ์ธ์šฉ ๊ฐœ์ธํ‚ค/๊ณต๊ฐœํ‚ค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.

๋”๋ณด๊ธฐ

1. Enter file in which to save the key (/home/user/.ssh/id_rsa): <return>

๊ฒฝ๋กœ๋ฅผ ์–ด๋””์— ์ €์žฅํ• ์ง€ ๋ฌผ์–ด๋ณด๋Š” ๊ฒƒ์ธ๋ฐ ๊ทธ๋ƒฅ ์—”ํ„ฐ๋ฅผ ์น˜๋ฉด ๊ธฐ๋ณธ ๊ฒฝ๋กœ์— ์ €์žฅ๋œ๋‹ค.

 

2. Enter passphrase (empty for no passphrase): <Type the passphrase>

passphrase๋Š” ์ผ์ข…์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋กœ ๋น„๊ณต๊ฐœํ‚ค๋ฅผ ์ž…๋ ฅํ•œ ๊ฐ’์œผ๋กœ ์•”ํ˜ธํ™” ํ•˜๋ฉฐ ๊ถŒ์žฅ ๊ฐ’์€ 10~30์˜ ๋ฌธ์ž์ด๊ณ  ์ƒ๋žต ๊ฐ€๋Šฅํ•˜๋‹ค. 

์ƒ๋žตํ•˜๋ฉด ๋ณด์•ˆ ํ™€์ด ๋  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฃผ์˜ํ•ด์•ผ ํ•œ๋‹ค๊ณ  ํ•˜๋‚˜, ์ž๋™๋กœ๊ทธ์ธ์„ ์›ํ•œ๋‹ค๋ฉด ์ƒ๋žต( ๊ทธ๋ƒฅ ์—”ํ„ฐ )ํ•ด์•ผํ•œ๋‹ค๊ณ  ํ•œ๋‹ค.

 

3. Enter same passphrase again: <Type the passphrase>

๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ํ™•์ธํ•˜๋Š” ๋‹จ๊ณ„์ด๋ฉฐ,

์œ„์˜ 2๋ฒˆ์—์„œ ์ž…๋ ฅํ•œ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋˜‘๊ฐ™์ด ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ 2๋ฒˆ์—์„œ ์•„๋ฌด๊ฒƒ๋„ ์ž…๋ ฅํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ์—”ํ„ฐ๋ฅผ ์น˜๋ฉด ๋œ๋‹ค.

 

Your identification has been saved in /home/user/.ssh/id_rsa.

Your public key has been saved in /home/user/.ssh/id_rsa.pub.

The key fingerprint is:

XX:XX:XX.... ๋ธ”๋ผ๋ธ”๋ผ

์™€ ๊ฐ™์€ ์•ˆ๋‚ด๋ฌธ์ด ๋‚˜์˜จ๋‹ค๋ฉด ์™„๋ฃŒ ๋œ ๊ฒƒ ์ด๋‹ค.

 

์ƒ์„ฑ ์™„๋ฃŒ ๋˜๋ฉด ์•„๋ž˜์˜ ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๋Š”๋ฐ ๊ฐ๊ฐ

 

  • id_rsa.pub : ๊ณต๊ฐœํ‚ค, ์•Œ๋ ค์ค„ ํ‚ค ๊ฐ’ / ํ•„์ˆ˜ ์ƒ์„ฑ
  • id_rsa : ๊ฐœ์ธํ‚ค, ์•Œ๋ ค์ฃผ๋ฉด ์•ˆ๋จ / ํ•„์ˆ˜ ์ƒ์„ฑ
  • authorized_keys : ๋ฆฌ๋ชจํŠธ์˜ .ssh ๋””๋ ‰ํ† ๋ฆฌ ์•„๋ž˜ ์œ„์น˜ํ•˜๋ฉด์„œ id_rsa.pub ํ‚ค์˜ ๊ฐ’์„ ์ €์žฅ / ์ƒ์„ฑ ๋˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ๋‹ค.

 

์„ ์˜๋ฏธํ•œ๋‹ค.

 

-b ์˜ต์…˜์„ ์ด์šฉํ•˜๋ฉด, ๋น„ํŠธ์ˆ˜๋ฅผ ์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ๊ตณ์ด ์‚ฌ์šฉ ํ•˜์ง€ ์•Š์•„๋„ ๊ดœ์ฐฎ๋‹ค.

ex ) $ ssh-keygen -t rsa -b 2048

 

 

 

More

๊ณต๊ฐœํ‚ค๋ฅผ ์•ˆ์ „ํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜๊ธฐ

$ chmod 700 ~/.ssh
$ chmod 600 ~/.ssh/id_rsa
$ chmod 644 ~/.ssh/id_rsa.pub
$ chmod 644 ~/.ssh/authorized_keys
$ chmod 644 ~/.ssh/known_hosts

ssh ๋””๋ ‰ํ† ๋ฆฌ๋Š” ๋งค์šฐ ์ค‘์š”ํ•œ ๋ณด์•ˆ ์ •๋ณด๊ฐ€ ๋‹ด๊ธด ๊ณณ์ž„์œผ๋กœ, ๊ถŒํ•œ ์„ค์ •์„ ๊ผญํ•ด์•ผํ•œ๋‹ค!

์œ„์™€ ๊ฐ™์€ ์„ค์ •์„ ๊ถŒ์žฅํ•œ๋‹ค๊ณ  ํ•˜๋‹ˆ ์„ค์ •ํ•ด์ฃผ์ž!