프린트 하기

OS 환경 : Oracle Linux 6.4, 9.6 (64bit)

 

DB 환경 : Oracle Database 19.27.0.0

 

에러 : 리눅스6 scp 사용시 no hostkey alg lost connection 메세지

리눅스6 에서 리눅스9 서버로 scp시 발생하는 메세지

1
2
3
# scp LINUX.X64_193000_db_home.zip 192.168.137.50:/root/
no hostkey alg
lost connection

 

 

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 9.6 (Plow)

 

 

scp 수신 서버 ssh 버전 확인

1
2
# ssh -V
OpenSSH_8.7p1, OpenSSL 3.2.2 4 Jun 2024

 

 

해결 방법 : ssh 설정에 rsa 방식을 추가하거나 sha-1 서명을 허용하는 명령어 수행

리눅스9 서버 ssh 설정에 예외 추가

1
2
3
# vi /etc/ssh/sshd_config
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

 

 

sshd 재시작

1
# systemctl restart sshd

위 방법을 해도 안되는 경우 아래 방법 사용

 

 

리눅스9 서버에서 아래 명령 사용

1
2
3
4
5
update-crypto-policies --set DEFAULT:SHA1
Setting system policy to DEFAULT:SHA1
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.

명령어 설명 :
시스템 전역에서 sha-1 서명을 다시 허용
이후 ssh의 ssh-rsa가 살아나서 구형 rhel6 클라이언트와 통신 가능
단점 : ssh뿐 아니라 시스템 전체(openssl 등)에 sha-1이 풀려 보안 기준이 내려가기 때문에 일시적 사용 후 반드시 원복 필요함

 

 

scp 재시도

1
2
3
4
5
6
7
# scp LINUX.X64_193000_db_home.zip 192.168.137.50:/root/
The authenticity of host '192.168.137.50 (192.168.137.50)' can't be established.
RSA key fingerprint is d1:2c:c3:d4:a5:56:7d:86:b9:10:ff:f2:d3:14:f5:6e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.137.50' (RSA) to the list of known hosts.
root@192.168.137.50's password:
LINUX.X64_193000_db_home.zip                       100% 2918MB 108.1MB/s   00:27

정상적으로 전송됨

 

 

scp 사용 후 원복

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.

 

 

원인 : SSH 프로토콜 지원 방식이 서로 달라서 발생하는 문제

SSH 프로토콜 지원 방식이 서로 달라서 발생하는 문제로
리눅스6의 openssh는 매우 오래된 버전이고, 리눅스9는 최신 보안 정책을 사용하기 때문에 서로 호환되는 host key 알고리즘이 없어서 연결이 끊긴 것
호스트키 교환 자체가 불가능해서 lost connection 메세지가 발생함
sshd에 rsa를 허용하는 구문을 넣어주거나 임시로 crypto-policies를 SHA1로 변경해주면 scp 사용이 가능함

 

 

참조 : 

https://access.redhat.com/solutions/6954602