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)
13197정성태12/17/20224309.NET Framework: 2079. .NET Core/5+ 환경에서 XmlSerializer 사용 시 System.IO.FileNotFoundException 예외 발생하는 경우파일 다운로드1
13196정성태12/16/20224428.NET Framework: 2078. .NET Core/5+를 위한 SGen(Microsoft.XmlSerializer.Generator) 사용법
13195정성태12/15/20224993개발 환경 구성: 655. docker - bridge 네트워크 모드에서 컨테이너 간 통신 시 --link 옵션 권장 이유
13194정성태12/14/20225045오류 유형: 833. warning C4747: Calling managed 'DllMain': Managed code may not be run under loader lock파일 다운로드1
13193정성태12/14/20225090오류 유형: 832. error C7681: two-phase name lookup is not supported for C++/CLI or C++/CX; use /Zc:twoPhase-
13192정성태12/13/20225102Linux: 55. 리눅스 - bash shell에서 실수 연산
13191정성태12/11/20226002.NET Framework: 2077. C# - 직접 만들어 보는 SynchronizationContext파일 다운로드1
13190정성태12/9/20226482.NET Framework: 2076. C# - SynchronizationContext 기본 사용법파일 다운로드1
13189정성태12/9/20227122오류 유형: 831. Visual Studio - Windows Forms 디자이너의 도구 상자에 컨트롤이 보이지 않는 문제
13188정성태12/9/20225948.NET Framework: 2075. C# - 직접 만들어 보는 TaskScheduler 실습 (SingleThreadTaskScheduler)파일 다운로드1
13187정성태12/8/20225848개발 환경 구성: 654. openssl - CA로부터 인증받은 새로운 인증서를 생성하는 방법 (2)
13186정성태12/6/20224373오류 유형: 831. The framework 'Microsoft.AspNetCore.App', version '...' was not found.
13185정성태12/6/20225368개발 환경 구성: 653. Windows 환경에서의 Hello World x64 어셈블리 예제 (NASM 버전)
13184정성태12/5/20224657개발 환경 구성: 652. ml64.exe와 link.exe x64 실행 환경 구성
13183정성태12/4/20224501오류 유형: 830. MASM + CRT 함수를 사용하는 경우 발생하는 컴파일 오류 정리
13182정성태12/4/20225214Windows: 217. Windows 환경에서의 Hello World x64 어셈블리 예제 (MASM 버전)
13181정성태12/3/20224616Linux: 54. 리눅스/WSL - hello world 어셈블리 코드 x86/x64 (nasm)
13180정성태12/2/20224842.NET Framework: 2074. C# - 스택 메모리에 대한 여유 공간 확인하는 방법파일 다운로드1
13179정성태12/2/20224263Windows: 216. Windows 11 - 22H2 업데이트 이후 Terminal 대신 cmd 창이 뜨는 경우
13178정성태12/1/20224748Windows: 215. Win32 API 금지된 함수 - IsBadXxxPtr 유의 함수들이 안전하지 않은 이유파일 다운로드1
13177정성태11/30/20225464오류 유형: 829. uwsgi 설치 시 fatal error: Python.h: No such file or directory
13176정성태11/29/20224400오류 유형: 828. gunicorn - ModuleNotFoundError: No module named 'flask'
13175정성태11/29/20225969오류 유형: 827. Python - ImportError: cannot import name 'html5lib' from 'pip._vendor'
13174정성태11/28/20224578.NET Framework: 2073. C# - VMMap처럼 스택 메모리의 reserve/guard/commit 상태 출력파일 다운로드1
13173정성태11/27/20225255.NET Framework: 2072. 닷넷 응용 프로그램의 스레드 스택 크기 변경
13172정성태11/25/20225120.NET Framework: 2071. 닷넷에서 ESP/RSP 레지스터 값을 구하는 방법파일 다운로드1
... 16  [17]  18  19  20  21  22  23  24  25  26  27  28  29  30  ...