Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

Azure App Service - Kudu SSH 환경에서 FTP를 이용한 파일 전송

Azure App Service의 Kudu SSH 환경에서 ftp를 사용하려면 우선 클라이언트부터 설치해야 합니다.

# apt install ftp

참고로, SSH로 들어갈 때마다 매번 저렇게 설치를 해야 합니다. (해당 인스턴스 환경이 cache되는 동안만 유효한 듯!)

그다음 FTP 세션으로 들어가 연결을 하고 로그인까지 마칩니다.

# ftp
> open 100.10.5.1
220 Microsoft FTP Service
Name (100.10.5.1:root): testusr
331 Password required
Password:
230 User logged in.
Remote system type is Windows_NT.

이후 파일 전송을 하면 되는데 다음과 같은 식으로 오류가 발생할 수 있습니다.

ftp> put /home/site/wwwroot/logs/t1.log
local: /home/site/wwwroot/logs/t1.log remote: /home/site/wwwroot/logs/t1.log
501 Server cannot accept argument.
ftp: bind: Address already in use

ftp> put /home/site/wwwroot/logs/t1.log /t1.log
local: /home/site/wwwroot/logs/t1.log remote: /t1.log
501 Server cannot accept argument.

왜냐하면 기본적으로 Active 모드로 동작하기 때문입니다. 따라서 Passive 모드로 변경을 하고,

ftp> passive
Passive mode on.

다시 put 명령어로 파일 전송을 하면 됩니다.

ftp> put /home/site/wwwroot/logs/t1.log /t1.log
local: /home/site/wwwroot/logs/t1.log remote: /t1.log
227 Entering Passive Mode (100,10,5,1,191,115).
125 Data connection already open; Transfer starting.
226 Transfer complete.
19495005 bytes sent in 0.22 secs (86.4566 MB/s)

원하는 동작을 모두 완료했으면 quit 명령어로 세션을 나갑니다.

ftp> quit
221 Goodbye.




참고로, put 명령어에 파일의 full path를 적어주면 remote 측도 그렇게 경로 구성이 되어 있어야 합니다. 그렇지 않은 경우 다음과 같은 식으로 오류가 발생하는데요,

ftp> put /home/site/wwwroot/logs/t1.log
local: /home/site/wwwroot/logs/t1.log remote: /home/site/wwwroot/logs/t1.log
501 Server cannot accept argument.

이럴 때는 put 명령어의 2번째 인자에 원격 측의 경로를 함께 기입하면 됩니다.

ftp> put /home/site/wwwroot/logs/t1.log /t1.log
local: /home/site/wwwroot/logs/t1.log remote: /t1.log
227 Entering Passive Mode (100,10,5,1,191,115).
125 Data connection already open; Transfer starting.
226 Transfer complete.
19495005 bytes sent in 0.22 secs (86.4566 MB/s)




한 가지 주의할 점이 있는데요, Linux의 ftp도 기본적으로는 FTP over SSL 기능을 지원하지 않습니다. 따라서, 대상 FTP 서버에서 "over SSL" 기능을 풀어야 하는데요, 예를 들어 지난번의 글에 설정한 FTP 서비스라면,

Azure - 윈도우 VM에서 FTP 여는 방법
; https://www.sysnet.pe.kr/2/0/12854

IIS의 "FTP SSL Settings"를 통해 "Require SSL connections"로 지정된 기본값을 "Allow SSL connection"으로 낮춰야 합니다. 물론, 이렇게 하면 평문으로 암호가 전달되기 때문에 Azure App Service <-> Azure VM 간의 통신에는 그나마 안전할 수 있지만, 자칫 외부에서 접속을 한다거나 할 때 평문 암호 전달이 될 수 있으므로 심각한 보안 허점이 될 수 있습니다. 따라서 그런 경우에는 NSG의 설정을 통해,

Azure VM의 서비스를 Azure Web App Service에서만 접근하도록 NSG 설정을 제한하는 방법
; https://www.sysnet.pe.kr/2/0/12704

FTP 서비스 포트에 대해 Azure 내부에서만 통신을 허용하는 식으로 구성하는 것이 바람직합니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 11/14/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 46  47  48  49  [50]  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12406정성태11/8/202013528.NET Framework: 966. C# 9.0 - (15) 최상위 문(Top-level statements) [5]파일 다운로드1
12405정성태11/8/202010884.NET Framework: 965. C# 9.0 - (14) 부분 메서드에 대한 새로운 기능(New features for partial methods)파일 다운로드1
12404정성태11/7/202011461.NET Framework: 964. C# 9.0 - (13) 모듈 이니셜라이저(Module initializers)파일 다운로드1
12403정성태11/7/202011461.NET Framework: 963. C# 9.0 - (12) foreach 루프에 대한 GetEnumerator 확장 메서드 지원(Extension GetEnumerator)파일 다운로드1
12402정성태11/7/202012063.NET Framework: 962. C# 9.0 - (11) 공변 반환 형식(Covariant return types) [1]파일 다운로드1
12401정성태11/5/202011093VS.NET IDE: 153. 닷넷 응용 프로그램에서의 "My Code" 범위와 "Enable Just My Code"의 역할 [1]
12400정성태11/5/20207985오류 유형: 679. Visual Studio - "Source Not Found" 창에 "Decompile source code" 링크가 없는 경우
12399정성태11/5/202011694.NET Framework: 961. C# 9.0 - (10) 대상으로 형식화된 조건식(Target-typed conditional expressions)파일 다운로드1
12398정성태11/4/202010254오류 유형: 678. Windows Server 2008 R2 환경에서 Powershell을 psexec로 원격 실행할 때 hang이 발생하는 문제
12397정성태11/4/202010434.NET Framework: 960. C# - 조건 연산자(?:)를 사용하는 경우 달라지는 메서드 선택 사례파일 다운로드1
12396정성태11/3/20208658VS.NET IDE: 152. Visual Studio - "Tools" / "External Tools..."에 등록된 외부 명령어에 대한 단축키 설정 방법
12395정성태11/3/202010050오류 유형: 677. SSMS로 DB 접근 시 The server principal "..." is not able to access the database "..." under the current security context.
12394정성태11/3/20208385오류 유형: 676. cacls - The Recycle Bin on ... is corrupted. Do you want to empty the Recycle Bin for this drive?
12393정성태11/3/20208918오류 유형: 675. Visual Studio - 닷넷 응용 프로그램 디버깅 시 Disassembly 창에서 BP 설정할 때 "Error while processing breakpoint." 오류
12392정성태11/2/202013125.NET Framework: 959. C# 9.0 - (9) 레코드(Records) [4]파일 다운로드1
12390정성태11/1/202011296디버깅 기술: 173. windbg - System.Configuration.ConfigurationErrorsException 예외 분석 방법
12389정성태11/1/202011005.NET Framework: 958. C# 9.0 - (8) 정적 익명 함수 (static anonymous functions)파일 다운로드1
12388정성태10/29/202010482오류 유형: 674. 어느 순간부터 닷넷 응용 프로그램 실행 시 System.Configuration.ConfigurationErrorsException 예외가 발생한다면?
12387정성태10/28/202011270.NET Framework: 957. C# - static 필드의 정보가 GC Heap에 저장될까요? [3]파일 다운로드1
12386정성태10/28/202011484Linux: 34. 사용자 정보를 함께 출력하는 리눅스의 ps 명령어 사용 방법
12385정성태10/28/20209296오류 유형: 673. openssl - req: No value provided for Subject Attribute CN, skipped
12384정성태10/27/202010544오류 유형: 672. AllowPartiallyTrustedCallers 특성이 적용된 어셈블리의 struct 멤버 메서드를 재정의하면 System.Security.VerificationException 예외 발생
12383정성태10/27/202011473.NET Framework: 956. C# 9.0 - (7) 패턴 일치 개선 사항(Pattern matching enhancements) [3]파일 다운로드1
12382정성태10/26/20209057오류 유형: 671. dotnet build - The local source '...' doesn't exist
12381정성태10/26/202010850VC++: 137. C++ stl map의 사용자 정의 타입을 key로 사용하는 방법 [1]파일 다운로드1
12380정성태10/26/20208171오류 유형: 670. Visual Studio - Squash_FailureCommitsReset
... 46  47  48  49  [50]  51  52  53  54  55  56  57  58  59  60  ...