Linux SCP 명령어 사용법

■ 파일을 원격지 서버에 복사
# 로컬 서버의 현재 디렉토리에 있는 abc.txt 파일을 원격지 서버( centos02 )의 nextman사용자의 tmp 디렉토리로 복사

[nextman@centos01 tmp]$ scp abc.txt nextman@centos02:~/tmp

 

■ 폴더를 원격지 서버에 복사( -r 옵션)
# 로컬 서버에 있는 /home/nextman/tmp/ccc 디렉토리를 원격지 서버(centos02)의 nextman 사용자 계정으로 /home/nextman/tmp 디렉토리 하위에  scp를 통해 복사.

[nextman@centos01 tmp]$ scp -r /home/nextman/tmp/ccc nextman@centos02:/home/nextman/tmp

# 원격지의 계정과 로컬 서버의 계정이 같다면(‘nextman’) 아래와 같이 생략해도 가능.

[nextman@centos01 tmp]$ scp -r /home/nextman/tmp/ccc centos02:/home/nextman/tmp

# 원격지 서버주소를 호스트명을 대신해 IP 주소 입력도 가능.

[nextman@centos01 tmp]$ scp -r /home/nextman/tmp/ccc nextman@192.168.192.130:/home/nextman/tmp

 

■ 원격지 서버의 파일을 로컬 서버로 복사
# 원격지 서버(centos02)의 nextman사용자의 tmp디렉토리에 있는 def.txt 파일을 로컬서버의 /home/nextman/tmp 디렉토리에 복사.

[nextman@centos01 tmp]$ scp nextman@centos02:~/tmp/def.txt /home/nextman/tmp

# 원격지 서버의 def.txt 파일을 로컬서버의 tmp디렉토리로 복사하는데 파일명을 fff.txt로 변경해서 복사.

[nextman@centos01 tmp]$ scp centos02:~/tmp/def.txt /home/nextman/tmp/fff.txt

 

■ 원격지 서버의 폴더를 로컬 서버로 복사( -r 옵션 )

[nextman@centos01 tmp]$ scp -r centos02:~/tmp/ddd /home/nextman/tmp

 

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다