Use SCP Command to Securely Transfer Files

SCP (Secure Copy)

SCP Command

  • SSH ๋ฅผ ์ด์šฉํ•ด network๋กœ ์—ฐ๊ฒฐ๋œ host๊ฐ„์— ํŒŒ์ผ์„ ์ฃผ๊ณ  ๋ฐ›๋Š” ๋ช…๋ น์–ด

    • SSH๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— SSH key file๊ณผ ๊ฐ™์€ Identity File์„ ์ด์šฉํ•ด ํŒŒ์ผ์„ ์†ก์ˆ˜์‹  ํ•  ์ˆ˜ ์žˆ๋‹ค

  • Local to Remote (๋ณด๋‚ด๊ธฐ)

  • Remote to Local (๊ฐ€์ ธ์˜ค๊ธฐ)

  • Remote to Remote (Host ๋ผ๋ฆฌ ์ „์†ก) ๋ชจ๋‘ ๊ฐ€๋Šฅํ•˜๋‹ค

Syntax

scp [options ...] [source] [target]

Options

  • -r

    • ์žฌ๊ท€์ ์œผ๋กœ ๋ชจ๋“  ํด๋”๋“ค์„ ๋ณต์‚ฌ

    • ํด๋”๋ฅผ ๋ณต์‚ฌํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ์˜ต์…˜

      • ์ „์†กํ•˜๊ณ ์ž ํ•˜๋Š” ๋Œ€์ƒ์€ ํด๋”๋กœ ์ง€์ •ํ•˜๋ฉด ๋œ๋‹ค

        • symbolic link๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ์—๋Š” target์— symbolic link๋ฅผ ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  symbolic link๊ฐ€ ๊ฐ€๋ฆฌํ‚ค๋Š” ํŒŒ์ผ ํ˜น์€ ํด๋”๋ฅผ ๋ณต์‚ฌํ•œ๋‹ค

  • -P

    • ssh ํฌํŠธ๋ฅผ ์ง€์ •ํ•˜๋Š” ์˜ต์…˜

  • -i

    • ssh ํ‚คํŒŒ์ผ๊ณผ ๊ฐ™์€ identity file์˜ ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ•˜๋Š” ์˜ต์…˜

  • -v

    • verbose ๋ชจ๋“œ๋กœ ์ƒ์„ธ๋‚ด์šฉ์„ ๋ณด๋ฉฐ ๋””๋ฒ„๊น…์„ ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค

  • -p

    • ํŒŒ์ผ์˜ ์ˆ˜์ • ์‹œ๊ฐ„๊ณผ ๊ถŒํ•œ์„ ์œ ์ง€ํ•œ๋‹ค

+

SCP๋กœ AWS EC2์— ํŒŒ์ผ ์ „์†กํ•˜๊ธฐ

ex)

scp -i [pem key ๊ฒฝ๋กœ] [์—…๋กœ๋“œํ•  ํŒŒ์ผ ๊ฒฝ๋กœ] [ec2 ์ฃผ์†Œ]:~

Last updated