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

scp 연결 시 "Permission denied" 오류 및 "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" 경고

SSH Tunnel을 통해 연결하려는 경우 scp로 무심코 포트 포워딩 값(예제에서는 10002)을 다음과 같이 사용하면 Permission denied 오류를 경험할 수 있습니다.

C:\temp> scp test.txt tusr@127.0.0.1:10002:~/test.txt
tusr@127.0.0.1's password:
Permission denied, please try again.
tusr@127.0.0.1's password:
Permission denied, please try again.
tusr@127.0.0.1's password:
tusr@127.0.0.1: Permission denied (publickey,password).
lost connection

왜냐하면 scp에서는 "tusr@127.0.0.1:10002:~/test.txt"와 같은 식으로 인자가 전달된 경우 "10002:~/test.txt" 값 전체를 디렉터리로 해석하기 때문에 실제로는 127.0.0.1:22로 연결하는 것과 같습니다. 결국 로컬 PC에 설치된 SSH 서버에 연결하는 것에 불과하므로 운에 따라서 저런 식으로 "Permission denied"가 나거나 전혀 다른 메시지가 보일 수 있습니다.

암튼, scp에서 포트 명시는 "-P" 옵션으로 해야 합니다.

scp -P 10002 test.txt tusr@127.0.0.1:~/test.txt




scp의 파일 관리가 좀 정교하지 않은 것 같은데, 여러 서버로 연결하다 보면 다음과 같은 식으로 오류가 발생할 때가 있습니다.

C:\temp> scp -P 10001 test.txt tusr@127.0.0.1:~/test.txt
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:r+KSN5MVmkV0+uBaYBoUQi5itgD/QxZakLaJ6PqiNco.
Please contact your system administrator.
Add correct host key in %USERPROFILE%/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in %USERPROFILE%/.ssh/known_hosts:1
ECDSA host key for [127.0.0.1]:10001 has changed and you have requested strict checking.
Host key verification failed.
lost connection

당황하지 마시고 해당 경로의 파일을 메모장으로 열면,

%USERPROFILE%\.ssh\known_hosts

다음과 같은 식으로 개행이 제대로 안 되어 저장이 되었을 수 있습니다.

127.0.0.1 ecdsa-sha2-nistp256 AAAAE2Vj...[생략]...7g6wVEtv8=[127.0.0.1]:10001 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...0ycb3kkOPMEe8=
[127.0.0.1]:10002 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...A0j0nwZ+1YBS8=

따라서 그냥 다음과 같이 개행시켜서 저장해 주면 됩니다.

127.0.0.1 ecdsa-sha2-nistp256 AAAAE2Vj...[생략]...7g6wVEtv8=
[127.0.0.1]:10001 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...0ycb3kkOPMEe8=
[127.0.0.1]:10002 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...A0j0nwZ+1YBS8=

또는 오류가 발생한 [127.0.0.1]:10001의 키 값이 엉뚱하게도 [127.0.0.1]:10002의 항목과 동일하게 설정된 경우도 있었습니다.

127.0.0.1 ecdsa-sha2-nistp256 AAAAE2Vj...[생략]...7g6wVEtv8=
[127.0.0.1]:10001 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...0ycb3kkOPMEe8=
[127.0.0.1]:10002 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...0ycb3kkOPMEe8=

저럴 때는 그냥 [127.0.0.1]:10001 항목의 값을 삭제하고,

127.0.0.1 ecdsa-sha2-nistp256 AAAAE2Vj...[생략]...7g6wVEtv8=
[127.0.0.1]:10002 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNo...[생략]...0ycb3kkOPMEe8=

저장한 후 다시 scp 작업을 하면 새롭게 [127.0.0.1]:10001의 host key 값을 저장하게 만들면 됩니다.




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







[최초 등록일: ]
[최종 수정일: 6/20/2019]

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

비밀번호

댓글 작성자
 




... 16  17  [18]  19  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
13178정성태12/1/20224832Windows: 215. Win32 API 금지된 함수 - IsBadXxxPtr 유의 함수들이 안전하지 않은 이유파일 다운로드1
13177정성태11/30/20225566오류 유형: 829. uwsgi 설치 시 fatal error: Python.h: No such file or directory
13176정성태11/29/20224488오류 유형: 828. gunicorn - ModuleNotFoundError: No module named 'flask'
13175정성태11/29/20226106오류 유형: 827. Python - ImportError: cannot import name 'html5lib' from 'pip._vendor'
13174정성태11/28/20224680.NET Framework: 2073. C# - VMMap처럼 스택 메모리의 reserve/guard/commit 상태 출력파일 다운로드1
13173정성태11/27/20225366.NET Framework: 2072. 닷넷 응용 프로그램의 스레드 스택 크기 변경
13172정성태11/25/20225178.NET Framework: 2071. 닷넷에서 ESP/RSP 레지스터 값을 구하는 방법파일 다운로드1
13171정성태11/25/20224786Windows: 214. 윈도우 - 스레드 스택의 "red zone"
13170정성태11/24/20225098Windows: 213. 윈도우 - 싱글 스레드는 컨텍스트 스위칭이 없을까요?
13169정성태11/23/20225682Windows: 212. 윈도우의 Protected Process (Light) 보안 [1]파일 다운로드2
13168정성태11/22/20224975제니퍼 .NET: 31. 제니퍼 닷넷 적용 사례 (9) - DB 서비스에 부하가 걸렸다?!
13167정성태11/21/20225013.NET Framework: 2070. .NET 7 - Console.ReadKey와 리눅스의 터미널 타입
13166정성태11/20/20224730개발 환경 구성: 651. Windows 사용자 경험으로 WSL 환경에 dotnet 런타임/SDK 설치 방법
13165정성태11/18/20224630개발 환경 구성: 650. Azure - "scm" 프로세스와 엮인 서비스 모음
13164정성태11/18/20225540개발 환경 구성: 649. Azure - 비주얼 스튜디오를 이용한 AppService 원격 디버그 방법
13163정성태11/17/20225479개발 환경 구성: 648. 비주얼 스튜디오에서 안드로이드 기기 인식하는 방법
13162정성태11/15/20226551.NET Framework: 2069. .NET 7 - AOT(ahead-of-time) 컴파일
13161정성태11/14/20225776.NET Framework: 2068. C# - PublishSingleFile로 배포한 이미지의 역어셈블 가능 여부 (난독화 필요성) [4]
13160정성태11/11/20225719.NET Framework: 2067. C# - PublishSingleFile 적용 시 native/managed 모듈 통합 옵션
13159정성태11/10/20228921.NET Framework: 2066. C# - PublishSingleFile과 관련된 옵션 [3]
13158정성태11/9/20225204오류 유형: 826. Workload definition 'wasm-tools' in manifest 'microsoft.net.workload.mono.toolchain' [...] conflicts with manifest 'microsoft.net.workload.mono.toolchain.net7'
13157정성태11/8/20225861.NET Framework: 2065. C# - Mutex의 비동기 버전파일 다운로드1
13156정성태11/7/20226769.NET Framework: 2064. C# - Mutex와 Semaphore/SemaphoreSlim 차이점파일 다운로드1
13155정성태11/4/20226265디버깅 기술: 183. TCP 동시 접속 (연결이 아닌) 시도를 1개로 제한한 서버
13154정성태11/3/20225746.NET Framework: 2063. .NET 5+부터 지원되는 GC.GetGCMemoryInfo파일 다운로드1
13153정성태11/2/20227025.NET Framework: 2062. C# - 코드로 재현하는 소켓 상태(SYN_SENT, SYN_RECV)
... 16  17  [18]  19  20  21  22  23  24  25  26  27  28  29  30  ...