Putty나 Filezilla FTP를 이용한 연결정보 및  ppk를 가져 올 수 있는 기능이 있음

AWS에서 메뉴얼에서 나오는 프로그램이라 다운로드 받아 보았다. 

WinSCP Downloads:  http://winscp.net/eng/download.php

 

 

AWS 메뉴얼: https://docs.aws.amazon.com/ko_kr/AWSEC2/latest/UserGuide/putty.html?icmpid=docs_ec2_console

 


 

배치 파일에서 winscp로 ftp 파일 업로드

 

bat파일에서 winscp을 이용해서 파일 업로드 

 

winscp는 PATH를 잡아주던가, 아니면 절대 경로로 써주면 됩니다.

아래는 파일을 접근해서 로그인후, 다운로드후 서버의 파일을 삭제하는 순서로 처리 되는 배치 파일 예제 입니다.

@ECHO OFF

for /f %%I in ('wmic os get localdatetime ^|find "20"') do set dt=%%I

set dt=%dt:~0,8%

 

E:

cd e:\backup\files\

 

REM winscp /log="e:\backup\files\logs\winscp_%dt%.log" /loglevel=0 /command "open ftp://아이디:패스워드@FTP주소:포트" "bi"  "mget bak_%dt%.tar.gz" "rm bak_%dt%.tar.gz" "exit"

 

winscp /command "open ftp://아이디:패스워드@FTP주소:포트" "bi" "cd BACK" "mget bak_%dt%.tar.gz" "rm bak_%dt%.tar.gz" "exit" 

(참고로, 사전에 tar.gz은 서버에서 압축을 root계정에서 cron으로 생성한걸 만들어 준다.)

 

결론은, e:\bakcupback\files폴더에 bak_YYYYMMDD.tar.gz로 다운로드 받게됩니다.

 

winscp에서 파일 삭제 명령: https://winscp.net/eng/docs/scriptcommand_rm

winscp에서 스크립트 명령들: https://winscp.net/eng/docs/scripting#commands

 

winscp에서 command-line옵션: https://winscp.net/eng/docs/commandline

 

로그파일 만들기

(예제)

 winscp.exe sftp://martin@example.com/ /log="C:\winscp.log" /loglevel=0

 

 

(Sytax)

 winscp.com [/log=<logfile> [/loglevel=<level>] [/logsize=[count*]<size>]]
            [/xmllog=<logfile> [/xmlgroups]] [/nointeractiveinput]

 

 

 

Commands

The following commands are implemented.

To see help for the command, read respective documentation article below or type command help <command> directly in console.

Command Description
call Executes arbitrary remote shell command
cd Changes remote working directory
checksum Calculates checksum of remote file
chmod Changes permissions of remote file
close Closes session
cp Duplicates remote file
echo Prints message onto script output
exit Closes all sessions and terminates the program
get Downloads file from remote directory to local directory
help Displays help
keepuptodate Continuously reflects changes in local directory on remote one
lcd Changes local working directory
lls Lists the contents of local directory
ln Creates remote symbolic link
lpwd Prints local working directory
ls Lists the contents of remote directory
mkdir Creates remote directory
mv Moves or renames remote file
open Connects to server
option Sets or shows value of script options
put Uploads file from local directory to remote directory
pwd Prints remote working directory
rm Removes remote file
rmdir Removes remote directory
session Lists connected sessions or selects active session
stat Retrieves attributes of remote file
synchronize Synchronizes remote directory with local one

 

 

Parameters

Parameters for winscp.exe executable:

winscp.exe site|workspace|folder
winscp.exe <session_url>[/path/[file]]
winscp.exe [mysession] [/sessionname=<name>]
winscp.exe [mysession] [/newinstance]
winscp.exe [mysession] /edit <path>
winscp.exe [mysession] /synchronize [local_directory] [remote_directory] [/defaults]
winscp.exe [mysession] /keepuptodate [local_directory] [remote_directory] [/defaults]
winscp.exe [mysession] /refresh [path]
winscp.exe [mysession] /upload file1 file2 file3 ... [/defaults]
winscp.exe [mysession] [/privatekey=<file>] [/hostkey=<fingerprint>]
winscp.exe [mysession] [/clientcert=<file>] [/certificate=<fingerprint>]
winscp.exe [mysession] [/passive[=on|off]] [/implicit|explicit]
winscp.exe [mysession] [/timeout=<sec>]
winscp.exe [mysession] [/rawsettings setting1=value1 setting2=value2 ...]
winscp.exe [/console] [/script=script_file] [/command command1 command2 ...]
           [/parameter // param1 ...]
winscp.exe [/log=<logfile>  [/loglevel=<level>] [/logsize=[count*]<size>]]
           [/xmllog=<logfile> [/xmlgroups]]
winscp.exe [/ini=<inifile>]
winscp.exe [/rawconfig config1=value1 config2=value2 ...]
winscp.exe /batchsettings <site_mask> setting1=value1 setting2=value2 ...
winscp.exe /keygen keyfile [/output=output] [/changepassphrase] [/comment=comment]
winscp.exe /update
winscp.exe /help

 

번호 제목 sitelink1 글쓴이 날짜 조회 수
243 Windows 11 Pro 환경의 WSL2(Windows Subsystem for Linux 2)에서 X11(그래픽 앱)을 실행   황제낙엽 2026.01.06 2675
242 경로 관련 별칭(alias)   황제낙엽 2025.12.19 2561
241 macOS 에서 finder 로 숨김 디렉토리, 파일을 조회   황제낙엽 2025.09.26 1654
240 특정 폴더 제외하고 가장 최근에 생성된 폴더 이름 가져오는 shell file 만들기   황제낙엽 2025.07.28 2601
239 [Copilot] WSL2 Ubuntu 실행 방식과 차이점   황제낙엽 2025.06.09 2578
238 [Gemini] docker pull 로 다운받은 ubuntu 이미지를 portainer 로 실행하여 접속   황제낙엽 2025.06.02 2587
237 Windows 11 Pro -> WSL2 (Ubuntu) -> Docker -> Portainer   황제낙엽 2025.05.30 2737
236 윈도우 11 설치 USB 만들기 가이드 https://blog.naver.com/cjs0308cjs/223694056158  황제낙엽 2025.01.10 4002
235 [bard] docker로 실행한 container에 터미널로 접속   황제낙엽 2024.02.01 3679
234 [2023. 11. 6.] 데이터베이스, GUI 클라이언트 환경의 Docker Compose 모음 https://blog.pages.kr/2819  황제낙엽 2024.01.29 3842
233 Docker Compose 문법 정리 (YAML)   황제낙엽 2024.01.29 3389
232 Docker Compose 명령어(실행,중지,삭제) https://docs.docker.com/compose/reference/  황제낙엽 2024.01.28 3864
231 Docker Compose 에 대한 이해와 사용법에 대한 포스팅 모음 https://docs.docker.com/compose/gettingstarted/  황제낙엽 2024.01.26 4104
230 Kubernetes 와 Docker 의 관계   황제낙엽 2024.01.26 3046
229 docker 를 windows 에서 실행하는 방법 3가지 정리   황제낙엽 2024.01.23 3756
228 windows + docker 설치에 대한 포스팅 모음   황제낙엽 2024.01.22 3553
227 윈도우 10 실행키 입력 명령어 목록 (Windows + R) https://haenny.tistory.com/217  황제낙엽 2023.07.12 7564
226 윈도우 10 "원격 데스크톱"의 "컴퓨터 목록" 정보 저장 위치 (from Bing)   황제낙엽 2023.07.11 4017
225 compress this drive to save disk space (이 드라이브를 압축하여 디스크 공간 절약)   황제낙엽 2023.05.09 4238
224 명령어 모음   황제낙엽 2023.05.06 3670