no image
AWS로 OpenVPN 간단하게 구축하기
아마존에서 제공하는 프리티어로 간단하게 OpenVPN 서버를 구축하면 요긴하게 자주 쓰입니다.매월 트래픽 100GB로 제공되기 때문에, 사용량을 고려하며 사용합시다. (넘으면 돈나옵니다.)  접근하려는 서비스에서 아마존 IP를 막는 경우도 잦아서,  VPN을 백퍼센트 사용 할 수 있는건 아닙니다.     1. 인스턴스 생성이미지는 저는 페도라쪽을 주로 다루다 보니, Amazon Linux를 그냥 사용했는데, 우분투나 SUSE Linux를 사용하시는것도 상관 없습니다만, Amazon Linux는 2023이 아닌 2로 선택해주세요.      2. 탄력적 IP(공인 IP) 생성좌측 스크롤 내리다 보시면 네트워크 및 보안 탭에서 탄력적 IP로 들어갑시다. 탄력적 IP(공인 IP)는 사용하지 않을 때 과금이 되므..
2024.07.17
no image
[Linux] Squid 프록시 설치
프록시 서버의 일종으로 간편하게 구성할 수 있는 장점이 있습니다.프록시 서버클라이언트가 자신을 통해서 다른 네트워크 서비스에 간접적으로 접속할 수 있게 해 주는 컴퓨터 또는 응용 프로그램, 서버와 클라이언트 사이에서 중계기로서 대리로 통신을 수행하는 기능을 가리켜 ‘프록시’. 그 중계 기능을 하는 것을 의미합니다.VPN공용망을 별도의 가상 사설망 처럼 통신, 프록시와 다른점은 VPN은 보안에 강합니다. 프록시는 공용으로 사용하기에 IP 우회하기에 좋다고 볼 수 있습니다.서버 구축 프로세스프록시 서버가 될 서버에 squid 설치/etc/sysctl.conf에 net.ipv4.ip_forward = 1, net.ipv6.conf.all.disable_ipv6 = 1 추가squid.conf 백업 후, vim ..
2023.09.21
[Linux] IPTables 개념
해당 패키지는 필요한 테이블을 선택하여 각 규칙을 정할 수 있는데, 클라우드 시스템에서는 가장 많이 사용되는 테이블은 NAT 입니다.  Iptables의 명령어 구조iptables [ -t 테이블 ] [ 액션 ] [ 체인 ] [ 매치 ] [ -j 타겟 ]exex 1) iptables -t nat -A PREROUTING -j DNAT -p tcp --dport 22222 --to-destination 172.27.0.208:22해석NAT 테이블을 사용하여 PREROUTING 정책을 추가한다(DNAT), 매치되는 22222포트를 사용하는 패킷은 DNAT로 처리하고 타겟은 172.27.0.208:22로 한다.ex 2) iptables -t nat -A POSTROUTING -j SNAT -o eth0 -d ..
2023.09.21
CentOS 6 repolist
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.confcat /etc/yum.repos.d/vault.repo[vault]name=CentOS-$releasever - Vaultbaseurl=http://vault.centos.org/centos/$releasever/os/$basearch/enabled=1gpgcheck=1EOFyum clean allyum repolist
2023.09.20
CentOS 7 repolist
- 공식# CentOS-Base.repo## The mirror system uses the connecting IP address of the client and the# update status of each mirror to pick mirrors that are updated to and# geographically close to the client. You should use this for CentOS updates# unless you are manually picking other mirrors.## If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line ins..
2023.09.20
no image
OpenSSL 설치 및 업그레이드
이 문서는 기록 보관 및 자료 공유입니다. 백퍼센트 신뢰하지는 말아주세요. KISA 권고https://knvd.krcert.or.kr/detailSecNo.do?IDX=5866  보안 취약점 정보 포털닫기 검색knvd.krcert.or.kr 영향을 받는 제품 및 해결 버전제품명취약점 (CVE-ID)영향받는 버전해결 버전OpenSSLCVE-2023-0286CVE-2022-4304CVE-2023-02153.03.0.81.1.11.1.1t1.0.21.0.2zgCVE-2022-4203CVE-2023-0216CVE-2023-0217CVE-2023-04013.0.0 ~ 3.0.73.0.8CVE-2022-44503.03.0.81.1.11.1.1t출처 : KISA 기본적으로 설치되어있는 OpenSSL 패키지 버전은 1..
2023.09.20
no image
[CVE-2023-38408] OpenSSH 업그레이드
이 문서는 기록 보관 및 자료 공유입니다. 백퍼센트 신뢰하지는 말아주세요. KISA 권고문https://knvd.krcert.or.kr/detailSecNo.do?IDX=5961  보안 취약점 정보 포털닫기 검색knvd.krcert.or.kr 취약 대상 버전 : 5.5 ~ 9.3p1관련 라이브러리 종속성이 매우 많으므로 인터넷 환경에서 구성하는 것을 추천합니다. 현재 구성된 테스트 서버의 스펙과 SSH 버전은 다음과 같습니다.centos 7.9 1vCore 1GB, SSH version 7.4p1 , OpenSSL 1.0.2k-fips 첫번째로 openssh를 제거합니다. 해당 패키지를 제거할 경우 현재 붙어있는 세션 이후로, CLI 재접속이 불가하므로 신중하게 합니다.rpm -e --nodeps ope..
2023.09.19
반응형

아마존에서 제공하는 프리티어로 간단하게 OpenVPN 서버를 구축하면 요긴하게 자주 쓰입니다.

매월 트래픽 100GB로 제공되기 때문에, 사용량을 고려하며 사용합시다. (넘으면 돈나옵니다.)

 

 

접근하려는 서비스에서 아마존 IP를 막는 경우도 잦아서,  VPN을 백퍼센트 사용 할 수 있는건 아닙니다.

리전 선택을 잘합시다.

 

 

 

 

 

1. 인스턴스 생성

이미지는 저는 페도라쪽을 주로 다루다 보니, Amazon Linux를 그냥 사용했는데, 우분투나 SUSE Linux를 사용하시는것도 상관 없습니다만, Amazon Linux는 2023이 아닌 2로 선택해주세요.

Arm은 범용성이 떨어지므로, x86을 고르는게 좋습니다.
보안 그룹 설정
키 페어가 최초 생성시에 없으니 생성합시다.

 

ppk로 하면 putty로 접근할때 변환 안해도 되서 편합니다.

 

 

 

 

 

2. 탄력적 IP(공인 IP) 생성

좌측 스크롤 내리다 보시면 네트워크 및 보안 탭에서 탄력적 IP로 들어갑시다.

 

탄력적 IP(공인 IP)는 사용하지 않을 때 과금이 되므로 생성 후에, 반드시 인스턴스에 연결합시다.

Static IP가 무려 공짜입니다.

 

 

 

 

 

3.  서버 접근

Port가 정상적으로 접근이 되는지 보통 텔넷을 주로 사용하는데, Windows 기능 켜기/끄기에서 텔넷 클라이언트를 설치합시다. (굳이 할 필요는 없습니다.)

 

 

잘 접근됩니다.

 

접근하기에 앞서 로그인하는 ID를 알아야 하는데, 아마존 메뉴얼에 명시되어 있습니다.

저는 Amazon Linux로 생성하였으니, ec2-user로 로그인하게 되겠습니다.

생성한 OS에 따라 ID가 다르니 확인합시다.

 

 

이후 SSH 접근 툴을 사용해야하는데 일반적으로 Putty를 사용합니다만, 모바텀이나 mremote건 서드파티 SSH 툴을 사용하는건 본인 자유입니다.

Putty를 사용할때는 Connection - SSH - Auth - Credentials 에서 키를 등록해주세요.

 

 

이후 Host Name에 ec2-user@탄력적 IP, Port는 별도로 설정한게 없으니 기본 포트인 22 로 입력하고, 해당 세션 값을 저장하기 위해 Saved Sessions에 이름 지정 후 저장을 누르시면 다음에도 해당 이름을 Load하여 재사용 할 수 있습니다.

 

해당 세션으로 Putty Configuration에서 Open을 누르게 되면 아래와 같이 SSH 세션에 접근 하게 됩니다.

 

 

 

 

4. 설치

일반적으로 OpenVPN을 설치하게 되면 조금 복잡스럽니다, 그냥 github에서 사람들이 배포하는걸로 사용하면 편하니 그걸로 사용합시다.

https://github.com/angristan/openvpn-install

 

GitHub - angristan/openvpn-install: Set up your own OpenVPN server on Debian, Ubuntu, Fedora, CentOS or Arch Linux.

Set up your own OpenVPN server on Debian, Ubuntu, Fedora, CentOS or Arch Linux. - angristan/openvpn-install

github.com

 

호환성에서 지원을 잘하는 걸로 보이네요

 

 

이제 호환성도 확인했으니 설치 해봅시다.

[ec2-user@ovpn ~]$ sudo -i
[root@ovpn ~]# yum install -y git

# 위에 설치 끝나고
[root@ovpn ~]# git clone https://github.com/angristan/openvpn-install.git
[root@ovpn ~]# cd openvpn-install
[root@ovpn ~]# ./openvpn-install.sh 

# openvpn-install.sh 가 실행안될 때
[root@ovpn ~]# chmod +x openvpn-install

 

 

위 같이 설정하고 나면 스크립트가 알아서 설치를 하는데 중간에 한번 ID를 기입하는 설정이 있습니다.

아래와 같이 나오니 지정하면 끝입니다.

 

설치가 끝나면 하단에 *.ovpn 이라는 파일이 생성이 되는데 이게 패스워들 대신 할 인증서 입니다.

(나중에 쓰이니 꼭 기억합시다.)

 

열어보면 conf 값과 인증서가 같이 들어있는 걸 보실 수 있을겁니다.

 

 

설치는 끝났으니 실행합시다.

[root@vpn ~]# systemctl start openvpn-server@server

 

는 실행이 안됩니다.

 

 

로그(/var/log/message)를 까봅시다.

server.conf가 없다고 합니다.

 

설정 값이 있는지 확인해봐야하니 설치 경로에 들어가서 확인해봅시다.

[root@vpn ~]# cd /etc/openvpn/

 

 

웬걸 온전히 다 있습니다.

 

보통 이럴 땐 systemd 설정이 잘못 된 경우가 많기 때문에 확인해봐야 할 것 같습니다.

[root@vpn ~]# systemctl status openvpn-server@server.service

 

systemd unit 위치를 확인 했으니 까봅시다.

역시나 WorkingDirectory 값이 잘못 되었습니다.

키보드 i를 누르고 입력모드로 들어간 후에 /etc/openvpn 으로 수정한 후 ESC - :wq - Enter

 

이제 잘 됩니다.

 

네트워크 인터페이스 잘 생성 되었습니다.

 

포트도 잘 올라왔습니다.

 

 

5. 접속

클라이언트용 OpenVPN을 설치합시다. 

https://openvpn.net/client/

 

OpenVPN Connect - VPN For Your Operating System | OpenVPN

Download the official OpenVPN Connect client VPN software for your operating system, developed and maintained by our experts. Get started with our VPN software.

openvpn.net

 

다운로드 받고 실행합시다.

 

 

설정 할 내역은 딱히 없고 Next 만 누르세요.

 

이제 *.ovpn 파일(4. 설치 내역 참고)을 SFTP던 FTP던 VPN을 접속할 PC로 가져와야합니다.

그냥 cat 으로 vpn 설정값을 열어준다음 아래처럼 클릭해서 긁어서 메모장에 열어서 Ctrl+v 하면 값을 가져 올 수도 있습니다.

 

 

만약에 메모장에 값을 복사한 경우라면 확장자를 ovpn으로 꼭 바꿔주세요.

 

UPLOAD FILE 클릭

 

 

이 상태에서 아까 저장한 *.ovpn 파일을 넣어줍시다.

 

파일을 Import 하였으면 Connect를 눌러주세요.

 

 

이렇게 CONNECTED가 나오면 접속 된겁니다.

 

- VPN Off

 

- VPN On

 

 

이렇게 구축이 완료되었습니다.

 

하지만 맨 처음에도 말했던 것 처럼 이런 AWS 공인 IP는 웹서비스에서 자체적으로 막는 경우가 잦으니 안되는 경우도 많습니다.

 

6. 여담

인증서는 하나당 하나의 사용자를 처리할 수 있습니다.

따라서 여러 사용자가 사용하기 위해서는 추가를 해야하는데, 이때 설치 때 사용하였던 스크립트로 사용자를 간편하게 추가 할 수 있습니다.

 

이렇게 추가된 *.ovpn 파일을 다른 사용자에게 주면 됩니다.

반응형

'Linux' 카테고리의 다른 글

[Linux] Squid 프록시 설치  (0) 2023.09.21
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
CentOS 7 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20

[Linux] Squid 프록시 설치

하녕
|2023. 9. 21. 15:11
반응형
  • 프록시 서버의 일종으로 간편하게 구성할 수 있는 장점이 있습니다.

  • 프록시 서버
    • 클라이언트가 자신을 통해서 다른 네트워크 서비스에 간접적으로 접속할 수 있게 해 주는 컴퓨터 또는 응용 프로그램, 서버와 클라이언트 사이에서 중계기로서 대리로 통신을 수행하는 기능을 가리켜 ‘프록시’. 그 중계 기능을 하는 것을 의미합니다.
  • VPN
    • 공용망을 별도의 가상 사설망 처럼 통신, 프록시와 다른점은 VPN은 보안에 강합니다. 프록시는 공용으로 사용하기에 IP 우회하기에 좋다고 볼 수 있습니다.

  • 서버 구축 프로세스
    1. 프록시 서버가 될 서버에 squid 설치
    2. /etc/sysctl.conf에 net.ipv4.ip_forward = 1, net.ipv6.conf.all.disable_ipv6 = 1 추가
    3. squid.conf 백업 후, vim /etc/squid/squid.conf 에서 필요한 설정 ( ACL 혹은 PORT 등)
    4. 프록시가 필요한 서버에 설정

준비물 : 프록시가 될 서버, 프록시를 사용 할 서버

 

- 공인망

공인망
공인망

- 폐쇄망

폐쇄망

 

폐쇄망

yum install -y squid

 

squid를 설치하면 기본적인 acl 정책이 들어가있는데, 다음과 같습니다.

폐쇄망으로 설정한 네트워크 대역대가 기본적으로 설정되어 있으므로, 별도의 설정을 추가하지는 않겠습니다.

 

 

IP 포워딩과 IPv6 비활성화 파라미터를 추가하고 반영한 후에 Squid를 재시작합니다.

echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf

sysctl -p

systemctl restart squid

 

 

 

wget 사용이 필요할 때

echo "https_proxy = http://192.168.0.108:3128" >> /etc/wgetrc
echo "http_proxy = http://192.168.0.108:3128" >> /etc/wgetrc
echo "ftp_proxy = http://192.168.0.108:3128" >> /etc/wgetrc

 

 

 

yum 사용이 필요할 때

echo "proxy=http://192.168.0.108:3128" >> /etc/yum.conf

yum clean all

 

이렇게 기본적인 wget, yum 사용만 필요할 경우에는 squid 프록시를 사용하게 간편하게 구축하여 사용할 수 있습니다.

단, 풀 프록시가 필요할 경우에는 OpenVPN 등을 통해 환경을 구성하는 것이 좋습니다.

반응형

'Linux' 카테고리의 다른 글

AWS로 OpenVPN 간단하게 구축하기  (0) 2024.07.17
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
CentOS 7 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20

[Linux] IPTables 개념

하녕
|2023. 9. 21. 13:46
반응형

해당 패키지는 필요한 테이블을 선택하여 각 규칙을 정할 수 있는데, 클라우드 시스템에서는 가장 많이 사용되는 테이블은 NAT 입니다.

 

 

  • Iptables의 명령어 구조
    • iptables [ -t 테이블 ] [ 액션 ] [ 체인 ] [ 매치 ] [ -j 타겟 ]
    • ex
      1. ex 1) iptables -t nat -A PREROUTING -j DNAT -p tcp --dport 22222 --to-destination 172.27.0.208:22
        • 해석
          NAT 테이블을 사용하여 PREROUTING 정책을 추가한다(DNAT), 매치되는 22222포트를 사용하는 패킷은 DNAT로 처리하고 타겟은 172.27.0.208:22로 한다.
      2. ex 2) iptables -t nat -A POSTROUTING -j SNAT -o eth0 -d 172.27.0.0/24 --to-source 172.27.0.162
        • 해석
          NAT 테이블을 사용하여 POSTROUTING 정책을 추가한다(SNAT), eth0 인터페이스로 나가는 172.27.0.0/24의 모든 ip 대역은 172.27.0.162의 주소로 변환된다.

  • 테이블 : 사용할 테이블 기본은 filter
    1. filter : 방화벽
    2. nat : 주소 변환
    3. mangle : 패킷 데이터 변경 특수 규칙 OR 성능향상 TOS
    4. raw : 넷필터의 연결추적 하위시스템과 독립적 동작 규칙

  • 액션 : 정책의 변경 추가 삭제 등
    1. -A : APPEND 정책 추가
    2. -I : INSERT 정책 삽입
    3. -D : DELETE 정책 삭제
    4. -R : REPLACE 정책 교체
    5. -F : FLUSH 모든 정책 삭제
    6. -P : POLICY 기본 정책 설정
    7. -:L : LIST 정책 나열
  • 체인 : 정책의 대해 어떤 행동을 취할 것인가?
    1. INPUT : 호스트를 향한 모든 패킷 (입력)
    2. OUTPUT : 호스트에서 발생하는 모든 패킷 (출력)
    3. FORWARD : 호스트가 목적지가 아닌 패킷, 경유지 (라우터)
    4. PREROUTING : 외부 패킷의 목적지 변경 INPUT으로 가야할 패킷을 FORWARDING
    5. POSTROUTING : 패킷이 OUTPUT에서 ip , port를 변경

  • 매치 : 출발지, 목적지, 인터페이스 등 지정
    1. -s : 출발지 매칭, 도메인 IP 주소 ,넷마스크 값을 이용하여 표기 (--source, --src)
    2. -d : 목적지 매칭, 도메인 IP 주소, 넷마스크 값을 이용하여 표기 (--destination, --dst)
    3. -p : 프로토콜과 매칭 대소문자는 구분하지 않음 ( TCP, UDP, ICMP 등)
    4. -i : 입력 인터페이스와 매칭 ( --in-interface)
    5. -o : 출력 인터페이스와 매칭 (--out-interface)
    6. -j : 매치되는 패킷을 어떻게 처리할지 지정 (--jump)
  • 타겟 : 패킷이 규칙과 일치할 때 매치가 취하는 정책
    1. ACCEPT : 패킷 허용
    2. DROP : 패킷을 버림
    3. REJECT : 패킷을 버리고 응답 패킷 전송
    4. LOG : 패킷을 syslog에 기록
    5. SNAT --to [주소] : 소스 IP를 변환
    6. DNAT --to [주소] : 목적지 IP를 변환
    7. RETURN : 호출 체인 내에서 패킷 처리를 계속함

  • 참조
    nat 기능 사용 시, /etc/sysctl.conf에 net.ipv4.ip_forward=1 추가해야함

 

  • 자주 사용하는 명령어
    1. iptables -nL -t {테이블} : 테이블 조회 
    2. iptables -F -t {테이블} : 테이블 초기화
    3. iptables save > /etc/sysconfig/iptables : 정책 저장
    4. iptables -t {테이블} -L {정책} --line-numbers : 테이블의 정책을 번호로 출력
    5. iptables -t {테이블} -D {정책} 숫자 : 선택한 테이블의 정책 삭제
반응형

'Linux' 카테고리의 다른 글

AWS로 OpenVPN 간단하게 구축하기  (0) 2024.07.17
[Linux] Squid 프록시 설치  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
CentOS 7 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20

CentOS 6 repolist

하녕
|2023. 9. 20. 17:25
반응형
sed -i 's/enabled=1/enabled=0/g' /etc/yum/pluginconf.d/fastestmirror.conf

cat <<EOF > /etc/yum.repos.d/vault.repo
[vault]
name=CentOS-$releasever - Vault
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
EOF

yum clean all
yum repolist

 

반응형

'Linux' 카테고리의 다른 글

[Linux] Squid 프록시 설치  (0) 2023.09.21
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 7 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20
[CVE-2023-38408] OpenSSH 업그레이드  (0) 2023.09.19

CentOS 7 repolist

하녕
|2023. 9. 20. 17:05
반응형

- 공식

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

- 카카오

[base]
name=CentOS-$releasever - Base
baseurl= http://mirror.kakao.com/centos/$releasever/os/$basearch/ 
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl= http://mirror.kakao.com/centos/$releasever/updates/$basearch 
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
 
[extras]
name=CentOS-$releasever - Extras
baseurl= http://mirror.kakao.com/centos/$releasever/extras/$basearch 
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl= http://mirror.kakao.com/centos/$releasever/centosplus/$basearch 
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

- 네이버

[base]
name=CentOS-$releasever - Base
baseurl=https://mirror.navercorp.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirror.navercorp.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirror.navercorp.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirror.navercorp.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
반응형

'Linux' 카테고리의 다른 글

[Linux] Squid 프록시 설치  (0) 2023.09.21
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20
[CVE-2023-38408] OpenSSH 업그레이드  (0) 2023.09.19
반응형

이 문서는 기록 보관 및 자료 공유입니다. 백퍼센트 신뢰하지는 말아주세요.

 

KISA 권고

https://knvd.krcert.or.kr/detailSecNo.do?IDX=5866 

 

보안 취약점 정보 포털

닫기 검색

knvd.krcert.or.kr

 

영향을 받는 제품 및 해결 버전

제품명 취약점 (CVE-ID) 영향받는 버전 해결 버전
OpenSSL CVE-2023-0286
CVE-2022-4304
CVE-2023-0215
3.0 3.0.8
1.1.1 1.1.1t
1.0.2 1.0.2zg
CVE-2022-4203
CVE-2023-0216
CVE-2023-0217
CVE-2023-0401
3.0.0 ~ 3.0.7 3.0.8
CVE-2022-4450 3.0 3.0.8
1.1.1 1.1.1t

출처 : KISA

 

기본적으로 설치되어있는 OpenSSL 패키지 버전은 1.0.2k-fips 입니다.

 

https://www.openssl.org/source

 

/source/index.html

Downloads The master sources are maintained in our git repository, which is accessible over the network and cloned on GitHub, at https://github.com/openssl/openssl. Bugs and pull patches (issues and pull requests) should be filed on the GitHub repo. Please

www.openssl.org

 

사전에 필요한 패키지를 설치합시다.

yum install -y gcc gcc-c++ perl pcre-devel zlib-devel perl-core make

 

포스팅 기준 최신 버전으로 설치를 진행하려고 합니다. 이후 버전이 필요하신 분은 상단 openssl URL을 참고하세요.

wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz

 

컴파일에 필요한 추가 옵션은 하단의 문서 혹은 압축을 푼 디렉토리 내부의 INSTALL 파일을 확인 하시면 됩니다.

https://wiki.openssl.org/index.php/Compilation_and_Installation

 

Compilation and Installation - OpenSSLWiki

The following page is a combination of the INSTALL file provided with the OpenSSL library and notes from the field. If you have questions about what you are doing or seeing, then you should consult INSTALL since it contains the commands and specifies the b

wiki.openssl.org

 

OpenSSL 1.1.0 and above

OpenSSL 1.1.0 changed the behavior of install rules. You should specify both --prefix and --openssldir to ensure make install works as expected.
The takeaway is /usr/local/ssl is used by default, and it can be overridden with both --prefix and --openssldir. The rule of thumb applies for path overrides: specify both --prefix and --openssldir.

해당 문서를 참고하였을 때, 1.1.0 이상 버전을 설치 할 때는 prefix와 openssldir을 지정하여야 작동 확인이 가능하다고 명시되어 있습니다. 따라서 되도록이면 경로 지정을 하는게 좋습니다.

prefix :
OpenSSL을 설치 할 디렉토리
openssldir : 
OpenSSL에 구성될 기본 인증서 및 키 저장소

zlib의 경우 데이터 압축으로 인해 네트워크의 전송 데이터를 줄일 수 있고, SSL/TLS 이전 버전의 호환성을 유지 할 수 있지만, CRIM 공격에 취약하므로 zlib는 사용하지 않겠습니다.

따라서 컨픽값은 다음과 같습니다.

./config --prefix=/opt/openssl --openssldir=/usr/local/ssl no-ssl2 no-ssl3

 


컨픽 설정 후 make && make test를 통해 빌드와 테스트를 진행합니다.

[root@test123 openssl-1.1.1w]# ./config --prefix=/usr/local/openssl --openssldir=/usr/local/ssl no-ssl2 no-ssl3

Operating system: x86_64-whatever-linux2
Configuring OpenSSL version 1.1.1w (0x1010117fL) for linux-x86_64
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************

[root@test123 openssl-1.1.1w]# make && make test

 

테스트가 정상적으로 끝나게 되면 다음과 같이 마지막에 표시가 됩니다.

 

빌드와 테스트가 끝났으니 설치를 하도록 합니다.

make install

 

정상적으로 설치가 되었다면, 위에서 설정한 경로 값으로 이동하여 확인해봅니다.

 

올바르게 설치가 된 것을 확인 할 수 있습니다.

 

그리고 설치된 openssl의 라이브러리와 바이너리 파일의 심볼릭 링크를 생성합니다.

ln -s /opt/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1
ln -s /opt/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
ln -s /opt/openssl/bin/openssl /bin/openssl

 

혹은 ldconfig을 이용하여 라이브러리 연동을 하셔도 됩니다.

echo "/opt/openssl/lib" >> /etc/ld.so.conf.d/openssl-1.1.1w.conf
ldconfig -v

 

마지막으로 정상적으로 설치되었는지 실행합시다.

 

반응형

'Linux' 카테고리의 다른 글

[Linux] Squid 프록시 설치  (0) 2023.09.21
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
CentOS 7 repolist  (0) 2023.09.20
[CVE-2023-38408] OpenSSH 업그레이드  (0) 2023.09.19
반응형

이 문서는 기록 보관 및 자료 공유입니다. 백퍼센트 신뢰하지는 말아주세요.

 

KISA 권고문

https://knvd.krcert.or.kr/detailSecNo.do?IDX=5961 

 

보안 취약점 정보 포털

닫기 검색

knvd.krcert.or.kr

 

취약 대상 버전 : 5.5 ~ 9.3p1

관련 라이브러리 종속성이 매우 많으므로 인터넷 환경에서 구성하는 것을 추천합니다.

 

현재 구성된 테스트 서버의 스펙과 SSH 버전은 다음과 같습니다.

centos 7.9 1vCore 1GB, SSH version 7.4p1 , OpenSSL 1.0.2k-fips

 

첫번째로 openssh를 제거합니다. 

해당 패키지를 제거할 경우 현재 붙어있는 세션 이후로, CLI 재접속이 불가하므로 신중하게 합니다.

rpm -e --nodeps openssh openssh-clients openssh-server

오류가 발생하여 원복이 필요할 경우에는 해당 패키지를 재설치하여, 원복 할 수 있습니다.

yum install -y openssh openssh-server openssh-client

 

패키지를 제거하게되면 ssh/sshd_config과 pam.d/sshd가 *.rpmsave으로 변경됩니다. (중요)

[root@test123 openssh-9.4p1]# rpm -e --nodeps openssh openssh-clients openssh-server
warning: /etc/ssh/sshd_config saved as /etc/ssh/sshd_config.rpmsave
warning: /etc/pam.d/sshd saved as /etc/pam.d/sshd.rpmsave

 

 

 

필요한 패키지

yum update && upgrade -y
yum install -y gcc zlib-devel openssl-devel pam-devel

gcc : 컴파일러

devel : 컴파일을 위한 라이브러리 패키지

각 패키지 확인

 

wget http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.3p2.tar.gz

wget 사용이 힘들 경우에는 Filezilla 같은 FTP 프로그램을 사용하도록 합니다.

 

tar -xvf openssh-9.3p2.tar.gz
cd openssh-9.3p2

이후 압축을 풀고 해당 디렉토리로 진입합니다.

 

컴파일을 하기에 앞서 OpenSSL 버전과 경로 확인이 필요합니다.

 

https://www.openssh.com/releasenotes.html

 

OpenSSH: Release Notes

OpenSSH 9.4 was released on 2023-08-10. It is available from the mirrors listed at https://www.openssh.com/. OpenSSH is a 100% complete SSH protocol 2.0 implementation and includes sftp client and server support. Once again, we would like to thank the Open

www.openssh.com

릴리즈 노트에 따르면, openssh 9.4 버전부터 openssl 1.1.1을 요구하므로 현재 설치되어있는 버전을 그대로 사용합니다.

 

OpenSSL 업그레이드 포스팅은 하단 링크를 참고하세요.

https://f0rest.tistory.com/entry/OpenSSL-%EC%97%85%EA%B7%B8%EB%A0%88%EC%9D%B4%EB%93%9C

 

보노보노

이것저것

f0rest.tistory.com

 

OpenSSL의 경로는 /bin/openssl, 버전은 CentOS7 기본 배포 버전인 OpenSSL 1.0.2k-fips 입니다.

요구사항을 모두 갖추었으니, 컴파일을 진행하겠습니다.

 

 

./configure --prefix=패키지를 설치 할 경로 --with-ssl-dir=OpenSSL이 설치된 위치 --with-pam --sysconfdir=sshd 설정 경로 --with-kerberos5

./configure --prefix=/opt/openssh --with-pam --sysconfdir=/etc/ssh --with-kerberos5
make && make install

#--with-ssl-dir 옵션은 별도로 컴파일 설치를 하지 않았기에 생략하였습니다.

간혹 PAM이 작동하지 않을 경우에는 --with-md5-passwords 옵션을 추가하여 조치를 취할 수 있습니다.

 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_rsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_rsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_rsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ecdsa_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ecdsa_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Unable to load host key "/etc/ssh/ssh_host_ed25519_key": bad permissions
Unable to load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available -- exiting.

컴파일을 끝내고 설치까지 완료하니까 다음과 같은 오류 메시지가 출력되었습니다.

기본적으로 생성되어있는 SSH 키파일에 대한 권한 오류로 저는 별도로 수정하였습니다.

chmod 400 /etc/ssh/ssh_*

 

 

다음과 같이 버전 확인을 하였을 때, 정상적으로 설치된 것을 확인 할 수 있습니다.

/opt/openssh/bin/ssh -V
OpenSSH_9.3p2, OpenSSL 1.0.2k-fips  26 Jan 2017

 

맨 처음 openssh를 제거하였을 때, 변경되었던 기존 설정 값을 전부 원복하여 줍니다.

cp /etc/ssh/sshd_config.rpmsave /etc/ssh/sshd_config
cp /etc/pam.d/sshd.rpmsave /etc/pam.d/sshd

 

원본이 유실되었을 경우, 제가 사용하는 설정 값을 같이 공유드립니다.

 

- /etc/ssh/sshd_config

 

#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
PermitRootLogin no
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
Match User root
  Banner /etc/ssh/banner_centos

 

- /etc/pam.d/sshd

#%PAM-1.0
auth       required     pam_sepermit.so
auth       substack     password-auth
auth       include      postlogin
# Used with polkit to reauthorize users in remote sessions
-auth      optional     pam_reauthorize.so prepare
account    required     pam_nologin.so
account    include      password-auth
password   include      password-auth
# pam_selinux.so close should be the first session rule
session    required     pam_selinux.so close
session    required     pam_loginuid.so
# pam_selinux.so open should only be followed by sessions to be executed in the user context
session    required     pam_selinux.so open env_params
session    required     pam_namespace.so
session    optional     pam_keyinit.so force revoke
session    include      password-auth
session    include      postlogin
# Used with polkit to reauthorize users in remote sessions
-session   optional     pam_reauthorize.so prepare

 

다음은 sshd 서비스를 다음과 같이 등록하였습니다.

cat <<EOF > /etc/systemd/system/sshd.service
[Unit]
Description=OpenSSH server 9.3p2
Wants=sshd-keygen.service

[Service]
ExecStart=/bin/sshd -D
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s

[Install]
WantedBy=multi-user.target

EOF

[root@test123 ~]# systemctl daemon-reload
[root@test123 ~]# systemctl restart sshd

[root@test123 ~]# systemctl status sshd
● sshd.service - OpenSSH server 9.3p2
   Loaded: loaded (/etc/systemd/system/sshd.service; disabled; vendor preset: enabled)
   Active: active (running) since Tue 2023-09-19 15:20:03 KST; 15min ago
 Main PID: 24446 (sshd)
   CGroup: /system.slice/sshd.service
           └─24446 sshd: /bin/sshd -D [listener] 0 of 10-100 startups

 

 

마지막으로 심볼릭을 생성하여 바로 실행이 가능하도록 지정하여 줍니다.

ln -s /opt/openssh/bin/ssh /bin/ssh
ln -s /opt/openssh/sbin/sshd /bin/sshd
ln -s /opt/openssh/bin/sftp /bin/sftp
ln -s /opt/openssh/bin/ssh-keygen /bin/ssh-keygen

ssh -V
OpenSSH_9.3p2, OpenSSL 1.0.2k-fips  26 Jan 2017

 

 

모든 구성이 끝났으므로 마지막으로 원격 접속 테스트를 해보도록 하겠습니다.

패스워드 접근

 

키 접근

키와 패스워드 모두 문제 없이 PAM이 동작하면서 정상적으로 접근되는 것을 확인 할 수 있습니다.

반응형

'Linux' 카테고리의 다른 글

[Linux] Squid 프록시 설치  (0) 2023.09.21
[Linux] IPTables 개념  (0) 2023.09.21
CentOS 6 repolist  (0) 2023.09.20
CentOS 7 repolist  (0) 2023.09.20
OpenSSL 설치 및 업그레이드  (0) 2023.09.20