프린트 하기 URL 복사

OS 환경 : Oracle Linux 10.2 (64bit)

 

DB 환경 : Oracle AI Database 23.26.3.0.0 ai

 

에러 : 리눅스6에서 리눅스10으로 scp 사용시 발생하는 no hostkey alg lost connection 메세지

리눅스6에서 리눅스10 서버로 scp시 발생하는 메세지
redhat linux 6에 있는 파일을 Oracle Linux 10으로 전송하여 할때 에러가 발생함

1
2
3
# scp p39581612_230000_Linux-x86-64_dbgoldimg.zip 192.168.137.50:/root/
no hostkey alg
lost connection

 

 

반대로 리눅스10에서 리눅스6으로 scp 가져오려해도 에러 발생함

1
2
# scp -O root@192.168.137.230:/NFS_DATA/Oracle_IMG/Linux/26ai/Patch/23.26.3/p39581612_230000_Linux-x86-64_dbgoldimg.zip /root/
Unable to negotiate with 192.168.137.230 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

 

 

scp 발신 서버 os 버전 확인

1
2
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)

 

 

scp 발신 서버 ssh 버전 확인

1
2
# ssh -V
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010

 

 

scp 수신 서버 os 버전 확인

1
2
# cat /etc/redhat-release
Red Hat Enterprise Linux release 10.2 (CentOS Stream)

 

 

scp 수신 서버 ssh 버전 확인

1
2
# ssh -V
OpenSSH_9.9p1, OpenSSL 3.5.5 27 Jan 2026

 

 

해결 방법 : Crypto Policy LEGACY 변경 및 ssh-rsa 알고리즘을 사용할수 있도록 임시 조치 후 진행

Crypto Policy LEGACY 변경 및 ssh-rsa 알고리즘을 사용할수 있도록 임시 조치 후 진행

 

 

리눅스9에서는 아래 명령을 입력하면 됬었지만 리눅스10에서는 에러가 발생함
(리눅스10에서는 SHA1 subpolicy가 제거되어서 안됨)

1
2
# update-crypto-policies --set DEFAULT:SHA1
Unknown policy `SHA1`: file `SHA1.pmod` not found in (., policies/modules, /etc/crypto-policies/policies/modules, /usr/share/crypto-policies/policies/modules)

참고 : 리눅스6 scp 사용시 no hostkey alg lost connection 메세지 ( https://positivemh.tistory.com/1288 )

 

 

아래 방법을 이용해야함
Crypto Policy를 임시로 LEGACY로 변경
리눅스10에서는 구형 리눅스6 서버의 ssh-rsa 알고리즘이 기본적으로 제한되어 있기 때문에 Crypto Policy를 임시로 LEGACY로 변경함

1
2
3
4
5
# update-crypto-policies --set LEGACY
Setting system policy to LEGACY
Note: System-wide crypto policies are applied on application start-up.
It is recommended to restart the system for the change of policies
to fully take place.

 

 

정책 변경 확인

1
2
# update-crypto-policies --show
LEGACY

변경됨

 

 

구형 리눅스6 서버 접속을 위한 SSH 호환성 설정
리눅스10 서버에서 접속할 리눅스6 서버에 대해서만 ssh-rsa 알고리즘을 사용할 수 있도록 별도 SSH 설정 파일을 생성

1
2
3
4
5
# cat > /etc/ssh/ssh_config.d/49-rhel6.conf <<'EOF'
Host 192.168.137.230
HostKeyAlgorithms ssh-rsa
PubkeyAcceptedAlgorithms ssh-rsa
EOF

 

 

SSH 설정 적용값 확인

1
2
3
# ssh -G 192.168.137.230 | grep -Ei 'hostkeyalgorithms|pubkeyacceptedalgorithms'
hostkeyalgorithms ssh-rsa
pubkeyacceptedalgorithms ssh-rsa

위와 같이 나오면 잘 적용된것임

 

 

SSH 접속 테스트
리눅스10 서버에서 RHEL6 서버로 SSH 접속이 정상적으로 가능한지 확인

1
2
3
4
5
6
7
8
# ssh root@192.168.137.230
The authenticity of host '192.168.137.230 (192.168.137.230)' can't be established.
RSA key fingerprint is SHA256:alRKUOgQ0uAiklzqJbEb16JaIvdsbo2kAHwpzhXs+gY.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.137.230' (RSA) to the list of known hosts.
root@192.168.137.230's password:
Last login: Mon Aug 31 07:43:57 2026 from 192.168.137.164

정상적으로 로그인되면 exit로 접속 종료

 

 

리눅스10 서버에서 SCP로 파일 가져오기
리눅스6 서버에서 리눅스10 서버로 직접 전송하는 방식 대신 리눅스10 서버에서 파일을 가져옴
구형 SCP 프로토콜을 사용하기 위해 -O 옵션을 사용함

1
2
3
# scp -O root@192.168.137.230:/NFS_DATA/Oracle_IMG/Linux/26ai/Patch/23.26.3/p39581612_230000_Linux-x86-64_dbgoldimg.zip /root/
root@192.168.137.230's password:
p39581612_230000_Linux-x86-64_dbgoldimg.zip                   100% 2378MB 109.7MB/s   00:21

잘 가져와짐

 

 

파일 전송 확인

1
2
# ls -lh /root/p39581612_230000_Linux-x86-64_dbgoldimg.zip
-rw-r--r--. 1 root root 2.4G Aug 31 07:26 /root/p39581612_230000_Linux-x86-64_dbgoldimg.zip

잘 가져와짐

 

 

SSH 호환성 설정 제거
파일 전송이 완료되면 임시로 생성한 리눅스6용 SSH 설정 파일을 삭제

1
# rm -f /etc/ssh/ssh_config.d/49-rhel6.conf

 

 

Crypto Policy 원복

1
2
3
4
5
# update-crypto-policies --set DEFAULT
Setting system policy to DEFAULT
Note: System-wide crypto policies are applied on application start-up.
It is recommended to restart the system for the change of policies
to fully take place.

 

 

원복 확인

1
2
# update-crypto-policies --show
DEFAULT

 

 

원인 : 구형 리눅스6과 리눅스10 간 SSH Host Key 알고리즘 호환성 문제

SSH Host Key 알고리즘 지원 방식이 서로 달라서 발생하는 문제로
RHEL6의 OpenSSH는 매우 오래된 버전(OpenSSH 5.3)이라 서버 Host Key로 ssh-rsa, ssh-dss 같은 구형 알고리즘을 제공하고
Oracle Linux 10은 최신 OpenSSH 및 강화된 Crypto Policy를 사용하기 때문에 해당 알고리즘을 기본적으로 허용하지 않음
이로 인해 SSH 인증 단계까지 도달하기 전에 Host Key 알고리즘 협상 자체가 실패하면서 no matching host key type found 또는 no hostkey alg, lost connection 메시지가 발생함
본문에서는 Oracle Linux 10에서 Crypto Policy를 임시로 LEGACY로 변경하고
접속 대상 RHEL6 서버에 한해서 HostKeyAlgorithms ssh-rsa, PubkeyAcceptedAlgorithms ssh-rsa 설정을 추가하여 SSH/SCP 연결이 가능하게끔 변경함
파일 전송 완료 후에는 추가한 SSH 호환성 설정을 제거하고 Crypto Policy를 DEFAULT로 원복하는 것이 필요함

 

 

참조 : 

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/security_hardening/using-system-wide-cryptographic-policies#excluding-an-application-from-following-systemwide-crypto-policies_using-system-wide-cryptographic-policies

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/security_hardening/using-system-wide-cryptographic-policies

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/security_hardening/index

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/considerations_in_adopting_rhel_10/security