리눅스 / 명령어 / scp

scp는 ssh 프로토콜을 이용하여 파일을 송수신하는 명령어이다.

  • local → remote
  • remote → local
  • remote → remote

모두 가능하다.

local → remote

파일 복사

# scp a.txt root@192.168.3.211:/temp/a.txt
root@192.168.3.211's password:
  • 명령어를 실행한 디렉토리에 있는 a.txt 파일을 192.168.3.211 컴퓨터에 root 계정으로 연결하여 복사한다.
  • 원격 컴퓨터에 /temp 디렉토리가 없으면 복사되지 않는다.
  • 원격 컴퓨터에 /temp 디렉토리가 있으면 a.txt로 복사된다. a.txt 파일이 이미 있다면 덮어쓴다.
  • root 계정의 비밀번호를 입력해야 진행된다.

처음 접속하는 거라면 아래와 같은 메시지가 나올 수 있다. yes 또는 y를 입력하고 진행한다.

The authenticity of host '192.168.3.211 (192.168.3.211)' can't be established.
ED25519 key fingerprint is SHA256:CWaawH0/RAuNqbjiXuu4WeYsqo+9JdOJi10uMBuXvl4.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?
# scp a.txt root@192.168.3.211:/temp
  • /temp 디렉토리가 없으면 a.txt 파일이 temp 파일로 복사한다.
  • /temp 디렉토리가 있으면 /temp/a.txt 파일로 복사한다.
# scp a.txt root@192.168.3.211:/temp/
  • /temp 디렉토리가 없으면 복사되지 않는다.
  • /temp 디렉토리가 있으면 /temp/a.txt 파일로 복사한다.
# scp b.txt c.txt root@192.168.3.211:/temp
  • 여러 파일을 동시에 복사할 수 있다.
# scp b.txt *.txt root@192.168.3.211:/temp
  • 와일드카드 등을 사용할 수 있다.
# scp -P 2000 a.txt root@192.168.3.211:/temp
  • ssh 포트가 22가 아니라면 -P 옵션으로 지정할 수 있다.

디렉토리 복사

# scp -r abc root@192.168.3.211:/temp/
  • 디렉토리를 복사할 때는 -r 옵션을 붙인다.
  • /temp 디렉토리가 없으면 복사되지 않는다.
  • /temp 디렉토리가 있으면 /temp/abc로 복사한다.
# scp -r abc root@192.168.3.211:/temp
  • /temp 디렉토리가 없으면 /temp 디렉토리를 만들고, 그 안에 abc 디렉토리 안의 파일 등을 복사한다.
  • /temp 디렉토리가 있으면 /temp 안에 abc 디렉토리를 복사한다.

remote → local

# scp -r root@192.168.3.211:/temp/abc ./
  • 192.168.3.211 컴퓨터에 root 계정으로 연결하여, /temp/abc 디렉토리를 현재 디렉토리로 복사한다.

remote → remote

# scp root@192.168.3.211:/temp/a.txt root@192.168.3.202:/temp/
root@192.168.3.202's password:
root@192.168.3.211's password:
  • 192.168.3.211에 있는 /temp/a.txt 파일을 192.168.3.202의 /temp 디렉토리에 복사한다.
  • 두 서버의 계정 암호를 다 묻는다.
같은 카테고리의 다른 글
페이팔 / 카카오뱅크 연결하는 방법

페이팔 / 카카오뱅크 연결하는 방법

최근 환율이 많이 올랐다. 그래서 페이팔에 있는 달러를 원화로 이체하기로 했다. 예전에 우리은행과 국민은행을 연결해두었는데, 최근에는 카카오뱅크를 주로 사용해서 카카오뱅크를 추가하고 이체하기로 정했다. 일단 할 것은 카카오뱅크를 페이팔 지갑에 추가하는 것인데... 많이 편해졌다. 은행계좌 연결에서 ka라고 치면... KAKAOBANK가 바로 나온다. KAKAOBANK를 선택하고... 계좌 유형을 예금으로 선택한 후, 계좌번호는 숫자만 넣는다. 동의 후 연결을 클릭하면 연결 ...

Ubuntu 18.04 Server / 설치하기

Ubuntu 18.04 Server / 설치하기

다운로드 Ubuntu Server 다운로드 페이지는 다음과 같다. https://ubuntu.com/download/server 최신 버전에 대한 안내가 주로 있으므로, 구버전을 다운로드하고 싶다면 아래 링크가 편하다. https://mirror.kakao.com/ubuntu-releases/ 가상 머신에 설치한다면 다운로드한 ISO 파일을 그대로 사용하면 되고, 물리 서버에 설치한다면 Rufus 같은 툴을 이용하여 부팅 USB를 만든다. 설치 설치 미디어로 부탕하고 잠시 기다리면 언어를 선택하는 화면이 나온다. 원하는 언어를 선택하고 엔터키를 누른다. 키보드 레이아웃을 정하고 ...

리눅스 / 명령어 / which, whereis, locate / 명령어 위치 찾기

명령어의 위치를 찾을 때 사용할 수 있는 명령어에는 which, whereis, locate가 있다. 명령어의 위치만 찾을 때는 which를 사용하고, 관련된 파일들의 위치까지 찾을 때는 whereis나 locate를 사용한다. which 명령어로 find 명령어를 찾는다. # which find /usr/bin/find whereis 명령어로 find 명령어를 찾는다. # whereis find find: /usr/bin/find /usr/share/man/man1/find.1.gz locate 명령어로 find 명령어를 찾는다. # locate find /usr/bin/find /usr/bin/find2perl /usr/bin/findmnt /usr/bin/nl-link-ifindex2name /usr/bin/nl-link-name2ifindex /usr/bin/oldfind /usr/lib64/python2.7/modulefinder.py /usr/lib64/python2.7/modulefinder.pyc /usr/lib64/python2.7/modulefinder.pyo /usr/sbin/btrfs-find-root /usr/sbin/findfs /usr/share/bash-completion/completions/findmnt /usr/share/doc/findutils-4.5.11 /usr/share/doc/findutils-4.5.11/AUTHORS /usr/share/doc/findutils-4.5.11/COPYING /usr/share/doc/findutils-4.5.11/ChangeLog /usr/share/doc/findutils-4.5.11/NEWS /usr/share/doc/findutils-4.5.11/README /usr/share/doc/findutils-4.5.11/THANKS /usr/share/doc/findutils-4.5.11/TODO /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_find.py /usr/share/doc/wpa_supplicant-2.6/examples/p2p/p2p_stop_find.py /usr/share/info/find-maint.info.gz /usr/share/info/find.info.gz /usr/share/locale/be/LC_MESSAGES/findutils.mo /usr/share/locale/bg/LC_MESSAGES/findutils.mo /usr/share/locale/ca/LC_MESSAGES/findutils.mo /usr/share/locale/cs/LC_MESSAGES/findutils.mo /usr/share/locale/da/LC_MESSAGES/findutils.mo /usr/share/locale/de/LC_MESSAGES/findutils.mo /usr/share/locale/el/LC_MESSAGES/findutils.mo /usr/share/locale/eo/LC_MESSAGES/findutils.mo /usr/share/locale/es/LC_MESSAGES/findutils.mo /usr/share/locale/et/LC_MESSAGES/findutils.mo /usr/share/locale/fi/LC_MESSAGES/findutils.mo /usr/share/locale/fr/LC_MESSAGES/findutils.mo /usr/share/locale/ga/LC_MESSAGES/findutils.mo /usr/share/locale/gl/LC_MESSAGES/findutils.mo /usr/share/locale/hr/LC_MESSAGES/findutils.mo /usr/share/locale/hu/LC_MESSAGES/findutils.mo /usr/share/locale/id/LC_MESSAGES/findutils.mo /usr/share/locale/it/LC_MESSAGES/findutils.mo /usr/share/locale/ja/LC_MESSAGES/findutils.mo /usr/share/locale/ko/LC_MESSAGES/findutils.mo /usr/share/locale/lg/LC_MESSAGES/findutils.mo /usr/share/locale/lt/LC_MESSAGES/findutils.mo /usr/share/locale/ms/LC_MESSAGES/findutils.mo /usr/share/locale/nl/LC_MESSAGES/findutils.mo /usr/share/locale/pl/LC_MESSAGES/findutils.mo /usr/share/locale/pt/LC_MESSAGES/findutils.mo /usr/share/locale/pt_BR/LC_MESSAGES/findutils.mo /usr/share/locale/ro/LC_MESSAGES/findutils.mo /usr/share/locale/ru/LC_MESSAGES/findutils.mo /usr/share/locale/rw/LC_MESSAGES/findutils.mo /usr/share/locale/sk/LC_MESSAGES/findutils.mo /usr/share/locale/sl/LC_MESSAGES/findutils.mo /usr/share/locale/sr/LC_MESSAGES/findutils.mo /usr/share/locale/sv/LC_MESSAGES/findutils.mo /usr/share/locale/tr/LC_MESSAGES/findutils.mo /usr/share/locale/uk/LC_MESSAGES/findutils.mo /usr/share/locale/vi/LC_MESSAGES/findutils.mo /usr/share/locale/zh_CN/LC_MESSAGES/findutils.mo /usr/share/locale/zh_TW/LC_MESSAGES/findutils.mo /usr/share/man/man1/find.1.gz /usr/share/man/man1/find2perl.1.gz /usr/share/man/man1/oldfind.1.gz /usr/share/man/man8/btrfs-find-root.8.gz /usr/share/man/man8/findfs.8.gz /usr/share/man/man8/findmnt.8.gz locate 명령어는 -n 옵션으로 출력 ...

보안 / IPS - Intrusion Prevention System

Intrusion Prevention System(IPS)은 네트워크 보안 장치로, 네트워크 트래픽을 실시간으로 모니터링하여 악의적인 활동이나 정책 위반을 탐지하고 이를 차단하는 기능을 수행합니다. IDS(침입 탐지 시스템)와 유사하지만, IPS는 탐지뿐만 아니라 능동적으로 위협을 차단하는 기능을 갖추고 있습니다. 주요 기능 실시간 모니터링 네트워크 트래픽을 실시간으로 분석하여 위협을 탐지합니다. 위협 차단 악의적인 활동이 발견되면 자동으로 해당 트래픽을 차단하여 네트워크를 보호합니다. 정책 적용 네트워크 보안 ...

리눅스 / 명령어 / cd / 다른 디렉토리로 이동하는 명령어

cd는 change directory의 약자로, 다른 디렉토리로 이동하는 명령어이다. cd 현재 로그인한 사용자의 홈 디렉토리로 이동한다. 일반적으로 root 계정이라면 /root로, 사용자 jb 계정이라면 /home/jb로 이동한다. cd ~user user의 홈 디렉토리로 이동한다. 다음과 같이 명령하면 jb 사용자의 홈 디렉토리로 이동한다. # cd ~jb cd 디렉토리명 지정한 디렉토리로 이동한다. 절대경로, 상대경로 다 사용할 수 있다. 다음과 같이 명령하면 /etc 디렉토리로 이동한다. # cd /etc 현재 ...

PuTTY / 사용법 / SSH / 자동 로그인하는 방법

PuTTY / 사용법 / SSH / 자동 로그인하는 방법

PuTTY로 리눅스 서버에 접속할 때 사용자 이름과 비밀번호를 입력합니다. 그 과정이 번거롭다면 Key를 이용하여 자동으로 로그인하도록 만들 수 있습니다. 그 방법을 정리합니다. 서버에서 Key 생성 서버에 root으로 로그인했고, 현재 디렉토리는 /root이라고 가정합니다. 다음과 같이 명령하여 Key를 생성합니다. 몇 가지 질문을 하는데 계속 엔터를 치면 됩니다. ssh-keygen .ssh 디렉토리로 이동합니다. cd .ssh id_rsa와 id_rsa.pub 두 개의 파일이 있습니다. id_rsa.pub 파일의 ...

리눅스 / 커널 / 버전 확인하는 방법

리눅스 커널 버전을 확인하는 방법은 여러 가지가 있습니다. 그 중 자주 사용하는 방법 두 가지를 소개합니다. uname uname 명령어는 시스템 정보를 출력하는 데 사용됩니다. -r 옵션을 사용하여 커널 버전을 확인할 수 있습니다. # uname -r 6.8.0-35-generic hostnamectl hostnamectl 명령어는 시스템의 호스트 이름과 관련된 정보를 관리하고 표시합니다. 여기에는 커널 버전 정보도 포함됩니다. # hostnamectl Static hostname: ubuntu-24-01 ...

외장 하드 케이스 / ipTIME HDD3135

외장 하드 케이스 / ipTIME HDD3135

남아도는 2.5인치 하드디스크를 활용하려고 아이피타임의 HDD3225를 구입했었습니다. 그런데 3.5인치도 있더군요. 그것도 4TB 대용량으로... 요즘 주로 노트북을 사용해서 어디 장착할 수도 없고 해서 3.5인치용 외장 하드 케이스를 구입했습니다. 구입한 제품은 HDD3135. 요것도 ipTIME 제품입니다. 공유기와 외장 하드 케이스는 ipTIME이 꽉 잡은 거 같네요. 하드 독(도킹 스테이션)을 살까도 고민했습니다. 여러 개의 HDD를 꽂을 수도 ...

아이피타임(ipTIME) 공유기 / 포트미러링 설정하는 방법

아이피타임(ipTIME) 공유기 / 포트미러링 설정하는 방법

포트 미러링(Port Mirroring)은 네트워크 장비, 특히 스위치에서 특정 포트에 들어오거나 나가는 트래픽을 다른 포트로 복사하여 전달하는 기능입니다. 이를 통해 네트워크 트래픽을 분석하거나 모니터링하는 데 사용할 수 있습니다. 주요 목적은 네트워크 상에서 발생하는 트래픽을 실시간으로 분석할 수 있게 하는 것으로, 보통 네트워크 성능 관리, 보안 침해 탐지, 문제 해결, 그리고 침입 탐지 ...

워드프레스 / 함수 / wp_is_mobile() / 모바일 접속 여부 판단하는 함수

워드프레스 / 함수 / wp_is_mobile() / 모바일 접속 여부 판단하는 함수

wp_is_mobile() wp_is_mobile()은 모바일 기기로 접속하면 true, 모바일 기기가 아니라면 false를 반환하는 함수이다. 모바일인지 아닌지 구분하는 기준은 $_SERVER 이다. wp_is_mobile()은 wp-includes/vars.php에 정의되어 있다. 예제 1 모바일이면 A를 출력한다. <?php if ( wp_is_mobile() ) { echo 'A'; } ?> 예제 2 모바일이 아니면 A를 출력한다. <?php if ( !wp_is_mobile() ) { echo 'A'; ...