이 글을 통해서 배워갈 내용
- SFTP 소개
- 실습 (Ubuntu 22.04 - Window)
SFTP 소개
SFTP는 Secure File Transfer Protocol의 약자로서
보안을 강화한 파일 전송 프로토콜입니다
암호화된 연결을 통해서 파일을 FTP 보다 안전하게
전송하고 관리하는데 사용됩니다
실습
윈도우에서 원격 우분투 호스트에 연결해서
파일을 올리고 내리는 실습을 해보겠습니다
A1.
먼저 ssh access를 확인합니다
(SFTP 가 SSH 위에서 동작하기 때문에
SSH 액세스가 없으면 SFTP 연결도 제대로 작동하지 않습니다)
윈도 CMD 혹은 Powershell에서 ssh 연결 확인
# ssh {유저이름}@{서버 ip혹은 host명}
ssh root@123.567.123.456
A2.
SSH연결이 된다면 sftp 연결
sftp root@123.567.123.456
A3.
남은 용량 확인
df -h
아래와 같이 용량을 확인할 수 있습니다
Size Used Avail (root) % Capacity
222.9GB 207.7GB 14.1GB 15.2GB 33%
A4.
위치 생성
mkdir 명령을 이용해서 호스트에 directory를 만들고
lmkdir 명령을 이용해서 로컬에 directory를 만듭니다
mkdir /fileupload
lmkdir C:\download
A5.
해당되는 위치로 이동하고
위치를 확인합니다
cd /fileupload
pwd
lcd C:\download
lpwd
A6.
get 명령어로 파일을 다운로드하고
put 명령어로 파일을 업로드합니다
"-r" 옵션은 해당 파일 혹은 폴더를 재귀적으로(하위 디렉터리 포함) 복사하거나 저장할 때 사용됩니다.
get 파일명
get hello
get -r filename newname
put 파일명
put hello
put -r filename newname
A7.
파일이 클 경우 압축을 해서 업로드하거나 다운로드합니다
cd c:\download
tar -czvf myfolder.tar.gz .
tar -xvzf myfolder.tar.gz -C /fileupload
A8.
파일에 권한을 변경하고자 한다면 아래의 명령어를 씁니다
"userID"를 "file"의 새로운 소유자로 설정
chown userID file
"groupID"를 "file"의 새로운 그룹으로 설정
chgrp groupID file
"publicfile"에 대해서 모든 사용자에 대해 읽기 쓰기 및 실행권한 부여(777)
chmod 777 publicfile
참조
sftp 접속 후에 help를 치고 내용을 확인해서 작성
bye Quit sftp
cd path Change remote directory to 'path'
chgrp [-h] grp path Change group of file 'path' to 'grp'
chmod [-h] mode path Change permissions of file 'path' to 'mode'
chown [-h] own path Change owner of file 'path' to 'own'
df [-hi] [path] Display statistics for current directory or
filesystem containing 'path'
exit Quit sftp
get [-afpR] remote [local] Download file
help Display this help text
lcd path Change local directory to 'path'
lls [ls-options [path]] Display local directory listing
lmkdir path Create local directory
ln [-s] oldpath newpath Link remote file (-s for symlink)
lpwd Print local working directory
ls [-1afhlnrSt] [path] Display remote directory listing
lumask umask Set local umask to 'umask'
mkdir path Create remote directory
progress Toggle display of progress meter
put [-afpR] local [remote] Upload file
pwd Display remote working directory
quit Quit sftp
reget [-fpR] remote [local] Resume download file
rename oldpath newpath Rename remote file
reput [-fpR] local [remote] Resume upload file
rm path Delete remote file
rmdir path Remove remote directory
symlink oldpath newpath Symlink remote file
version Show SFTP version
!command Execute 'command' in local shell
! Escape to local shell
? Synonym for help
필요시 putty를 다운받고 아래와 같이 secure key를 사용해서 접속도 가능합니다
psftp -i "경로\파일명.ppk" root@주소
'DevOps > Linux' 카테고리의 다른 글
Ubuntu 22.04 LTS (Jammy Jellyfish) Postgresql 16으로 버전업 하기 (0) | 2023.09.23 |
---|---|
우분투에서 PostgreSQL 설치하기: 초간단 레시피 (0) | 2023.09.09 |
[Node.js] CI/CD 구축 - Github Actions, Ubuntu 22, vultr (0) | 2023.08.29 |
윈도우 Hyper-V 가상화 한줄설명 및 간단 사용방법 (0) | 2023.08.16 |
도커(Docker)를 이용한 컨테이너 관리하기: 설치부터 볼륨생성까지 (1) | 2023.04.08 |