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 글쓴이 날짜 조회 수
155 인증 오류가 발생했습니다(코드:0x800706be) file https://answers.microsoft.com/en-us/wind...a3b73f86d8  황제낙엽 2019.10.01 193
154 Can't use copy paste In Windows 10 (Clear your clipboard) https://www.drivereasy.com/knowledge/sol...t-working/  황제낙엽 2019.08.19 306
» WinSCP free ftp 클라이언트 프로그램 + DOS bat 파일로 파일 업로드 https://blog.edit.kr/entry/WinSCP-free-f...8%EB%9E%A8  황제낙엽 2019.07.26 75
152 defaultuser0 <- 수상한 계정 file https://answers.microsoft.com/en-us/wind...9cd?auth=1  황제낙엽 2019.07.22 877
151 windows 10 안전모드 부팅 file   황제낙엽 2019.07.19 189
150 wscript 와 cscript   황제낙엽 2019.07.19 57
149 Malware Zero Kit (MZK) - 보조 악성코드 제거 스크립트 file http://mzk.co.kr  황제낙엽 2019.06.11 130
148 윈도우 10 시작 프로그램 폴더   황제낙엽 2019.06.03 237
147 윈도우 7~10 의 바탕화면 보기 기능의 단축키   황제낙엽 2019.04.18 108
146 윈도우 터치 키보드 비활성화하기 https://msparkms.tistory.com/entry/윈...화-끄기  황제낙엽 2019.04.15 140
145 inspect.exe (for win10) https://www.omnibuscode.com/board/index...._srl=52344  황제낙엽 2019.02.11 369
144 64bit x86 PC Window {우분투 리눅스 (QEMU로 arm64 커널을 에뮬레이션)} file http://jake.dothome.co.kr/qemu/  황제낙엽 2018.11.27 994
143 공유된 폴더를 삭제했을때 공유 정보에서 제거하는 방법   황제낙엽 2018.10.05 109
142 윈도우 시작시 자동으로 구동하는 프로그램 제거(삭제) file   황제낙엽 2018.09.22 400
141 OS 즉시 종료 명령어 - shutdown /s /t 0   황제낙엽 2018.09.02 139
140 [윈도우10] '이 항목을 찾을 수 없습니다'라고 뜨면서 폴더삭제가 안 돼요 https://kin.naver.com/qna/detail.nhn?d1i...jemg%3D%3D  황제낙엽 2018.08.07 906
139 shutdown file https://terms.naver.com/entry.nhn?docId=...ryId=59321  황제낙엽 2018.07.06 124
138 다른 계정으로 전환하는 명령어(sudo / su / su -) file http://www.leafcats.com/168  황제낙엽 2018.06.24 615
137 ttyname failed 오류 처리방법 file http://bemeal2.tistory.com/119  황제낙엽 2018.06.13 941
136 remote 원격 접속시 인증 오류 (CredSSP 암호화 Oracle 수정 때문일 수 있습니다) file https://support.microsoft.com/ko-kr/help...ch-13-2018  황제낙엽 2018.05.31 1439